Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.8.2, 5.0.2
Description
QApplication::queryKeyboardModifiers() may return out-of-date values under Qt/Cocoa if the current application is not active. Internally this is due to an issue with the GetCurrentEventKeyModifiers() function that queryKeyboardModifiers() currently uses on Mac.
See http://lists.apple.com/archives/cocoa-dev/2005/Oct/msg01317.html and http://www.cocoabuilder.com/archive/cocoa/87836-getting-the-current-state-of-the-modifier-keys.html for more details.
Sample app:
#include <QtCore/QDebug> #include <QtGui/QApplication> #include <QtGui/QDragEnterEvent> #include <QtGui/QWidget> struct TestWidget : public QWidget { virtual void dragEnterEvent(QDragEnterEvent* e) { e->accept(); } virtual void dragMoveEvent(QDragMoveEvent*) { qDebug() << "active keyboard modifiers" << QApplication::queryKeyboardModifiers(); } }; int main(int argc, char** argv) { QApplication app(argc, argv); TestWidget* tw = new TestWidget; tw->setAcceptDrops(true); tw->resize(300,300); tw->show(); return app.exec(); }
Steps to reproduce:
1. Build and run test app under Qt/Cocoa 4.8
2. Bring up a Finder window and focus it, so that the test app's window loses focus
3. Drag a file from Finder over the test app's window and whilst dragging the file around over the window, press and hold different modifier keys
The terminal output should change to indicate the current modifier keys being held for each drag move event. The keyboard modifier information does not update however.