diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-04-05 13:34:12 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-04-07 18:08:58 +0000 |
commit | 49163ca689562a4a000490fb137e5c9533684471 (patch) | |
tree | 5e908a4095078490ed5ecab8d7d606e6fcc1adf6 | |
parent | 3d7c4e064f0a41dc15899a584c1ec0f9ba345c84 (diff) |
Android: fix Menu and Back key handling
Don't quit on Back key release when Back shortcut was accepted and
likewise for the Menu key, don't trigger the platform menubar if Menu
shortcut was accepted.
Change-Id: Ifde87cbc2d95be1beb90ca59f55889b83a90ff02
Task-number: QTBUG-59670
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index a3b2c4c1e4..56f112c36c 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2027,13 +2027,23 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE window = QGuiApplication::focusWindow(); } +#if defined(Q_OS_ANDROID) + static bool backKeyPressAccepted = false; + static bool menuKeyPressAccepted = false; +#endif + #if !defined(Q_OS_OSX) // FIXME: Include OS X in this code path by passing the key event through // QPlatformInputContext::filterEvent(). if (e->keyType == QEvent::KeyPress && window) { if (QWindowSystemInterface::handleShortcutEvent(window, e->timestamp, e->key, e->modifiers, - e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers, e->unicode, e->repeat, e->repeatCount)) + e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers, e->unicode, e->repeat, e->repeatCount)) { +#if defined(Q_OS_ANDROID) + backKeyPressAccepted = e->key == Qt::Key_Back; + menuKeyPressAccepted = e->key == Qt::Key_Menu; +#endif return; + } } #endif @@ -2050,8 +2060,6 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE else ev.setAccepted(false); - static bool backKeyPressAccepted = false; - static bool menuKeyPressAccepted = false; if (e->keyType == QEvent::KeyPress) { backKeyPressAccepted = e->key == Qt::Key_Back && ev.isAccepted(); menuKeyPressAccepted = e->key == Qt::Key_Menu && ev.isAccepted(); |