Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.3.1, 5.5.0
-
mac os 10.9 OS X 10.10
Description
on Mac when an user presses "Ctrl + left click", applications usually interpret it as "right click", because old Mac mouse has only one button.
Qt therefore automatically translates "Ctrl+Left Click" to "right click". But we don't want this feature for our application, we want it to be "Ctrl+left click".
In the Qt4 era, we used to do a trick in the macEvent function, such that whenever we see "Ctrl+Left click", we mark a flag and handle this event differently.
#ifdef _APPLE_
bool SomeWidget::macEvent(EventHandlerCallRef, EventRef event)
{
if ( event is ctrl+left )
return false;
}
bool GLCanvas::macEventFilter (EventHandlerCallRef caller, EventRef event)
{ return false; }#endif
We recently moved to Qt5. Since macEvent doesn't exist anymore, we changed our code to the following:
bool SomeWidget::nativeEvent(const QByteArray & eventType, void * message, long * result)
{
if (eventType == "mac_generic_NSEvent")
{
EventRef ev = static_cast<EventRef>(message);
if ( .. event is ctrl+left click...)
{ m_isRightClick = true; } }
else
return false;
}
but this doesn't work anymore, because on Mac nativeEvent never gets called.
the attachment is a simple program that can reproduce this issue.
it is modified from the helloGL example. I simply added a nativeEvent function to the QGLWidget.
the same program can call into nativeEvent on Windows, but won't under Mac.
Is this a bug or just a missing implementation?
the Document on this page is very unclear.
http://qt-project.org/doc/qt-5/qwidget.html#nativeEvent
it doesn't give any example of using nativeEvent under mac, although it says nativeEvent replaces macEvent.
Inside the event type table, it only lists:
Windows "windows_generic_MSG" MSG * LRESULT
it doesn't mention Mac event type (mac_generic_NSEvent) at all?
it also doesn't say how to check the event type. is it a string or enum?
Attachments
For Gerrit Dashboard: QTBUG-40116 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
198865,5 | macOS: Deliver native events to windows, as well as to event filters | dev | qt/qtbase | Status: MERGED | +2 | 0 |