Details
Description
Get too many press/release events when clicking only once on the android back-key. Building for arm7/android.
Motivation is to make a pressAndHold event for the back-key, then I found this issue. A test example is attached.
First, creating a default qt/cpp project. Installing an event-filter to the main.cpp/app to filter away auto-repeat events when holding down a key.
When printing out what happens, I see this when pressing down (and holding down for some seconds) and then releases the Android back-key. The log below is both from the event-filter and from the application, see attached source code for details. Note that the application get two press events and one release event.
Application snippet:
FocusScope { focus: true Keys.onPressed: { event.accepted = true console.debug("Application onPressed") } Keys.onReleased: { event.accepted = true console.debug("Application onReleased") } }
Eventfilter snippet:
bool KeyEventFilter::eventFilter(QObject *obj, QEvent *e){ if(!(e->type() == QEvent::KeyPress || (e->type() == QEvent::KeyRelease))) return QObject::eventFilter(obj, e); QKeyEvent *keyEvent = static_cast<QKeyEvent*>(e); if(keyEvent->isAutoRepeat()) { e->ignore(); return true; } qDebug() << "Filtered event: " << keyEvent->key() << e->type() << keyEvent->timestamp(); return QObject::eventFilter(obj, e); }
Bug: I would have assumed only one press event to the application.
D/libAndroidBackTest.so(31135): ..\AndroidBackTest\keyeventfilter.cpp:22 (virtual bool KeyEventFilter::eventFilter(QObject*, QEvent*)): Filtered event: 16777313 6 21383
D/libAndroidBackTest.so(31135): ..\AndroidBackTest\keyeventfilter.cpp:22 (virtual bool KeyEventFilter::eventFilter(QObject*, QEvent*)): Filtered event: 16777313 6 21383
D/libAndroidBackTest.so(31135): qrc:/main.qml:32 (onPressed): qml: Application onPressed
D/libAndroidBackTest.so(31135): ..\AndroidBackTest\keyeventfilter.cpp:22 (virtual bool KeyEventFilter::eventFilter(QObject*, QEvent*)): Filtered event: 16777313 6 21885
D/libAndroidBackTest.so(31135): ..\AndroidBackTest\keyeventfilter.cpp:22 (virtual bool KeyEventFilter::eventFilter(QObject*, QEvent*)): Filtered event: 16777313 6 21885
D/libAndroidBackTest.so(31135): qrc:/main.qml:32 (onPressed): qml: Application onPressed
D/libAndroidBackTest.so(31135): ..\AndroidBackTest\keyeventfilter.cpp:22 (virtual bool KeyEventFilter::eventFilter(QObject*, QEvent*)): Filtered event: 16777313 7 23292
D/libAndroidBackTest.so(31135): ..\AndroidBackTest\keyeventfilter.cpp:22 (virtual bool KeyEventFilter::eventFilter(QObject*, QEvent*)): Filtered event: 16777313 7 23292
D/libAndroidBackTest.so(31135): qrc:/main.qml:36 (onReleased): qml: Application onReleased
Attachments
For Gerrit Dashboard: QTBUG-45340 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
110354,3 | Pass on the auto repeat information for key events | 5.5 | qt/qtbase | Status: MERGED | +2 | 0 |