I am making a Qt application and want to intercept keypresses at a deeper level. To do this I overrided the QWidget::macEvent() function to intercept the EventRef parameter.
For different events (i.e. keyboard events, mouse events, window events) EventRef is equal to the following values:
0×104d649f0
0×101425740
0×104d649f0
0×101485950
0×101425740
0×101485950
How can I tell if the event is a keyboard event? And how can I find out which key was pressed? I’ve looked at event handling documentation and most of them don’t mention EventRef. Some articles mention how EventRef is the Carbon event derived from the Cocoa NSEvent event.
After some guessing work, and looking at this chapter from a book, I’ve succeeded in interpreting the EventRef object for keypresses in Qt applications:
MyProject.pro: Include
Carbonframework:MyWidget.h: override QWidget::macEvent()
MyWidget.cpp: