From 49163ca689562a4a000490fb137e5c9533684471 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 5 Apr 2017 13:34:12 +0200 Subject: 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 --- src/gui/kernel/qguiapplication.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') 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(); -- cgit v1.2.3