summaryrefslogtreecommitdiff
path: root/src/controls/qquickmenupopupwindow.cpp
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2013-09-05 17:28:06 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-12 19:16:36 +0200
commit82081e737038262c82c2e408d412fc80a607bf9f (patch)
treee7d6a064648b64b95f4b4a7c05c407b1e776c65a /src/controls/qquickmenupopupwindow.cpp
parent6bcacdecb8445a5ad9a31f6bdac99cde076e6295 (diff)
downloadqtquickcontrols-82081e737038262c82c2e408d412fc80a607bf9f.tar.gz
Menu: Fix keyboard navigation on Windows
The Windows QPA plugin doesn't trigger activated window events for popups, resulting on the popup window not being the application focus window, and therefore, the popup window's content item not getting focus. This results in key pressed events not being sent to the menu item. We workaround this by emitting the window activated event ourselves right after the popup window is exposed. Task-number: QTBUG-33175 Change-Id: I77d1eb33b71af2232a6be6d0f7c6b480bffc10d4 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/controls/qquickmenupopupwindow.cpp')
-rw-r--r--src/controls/qquickmenupopupwindow.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/controls/qquickmenupopupwindow.cpp b/src/controls/qquickmenupopupwindow.cpp
index b44b082c..dd68b15c 100644
--- a/src/controls/qquickmenupopupwindow.cpp
+++ b/src/controls/qquickmenupopupwindow.cpp
@@ -42,14 +42,15 @@
#include "qquickmenupopupwindow_p.h"
#include <qguiapplication.h>
+#include <qpa/qwindowsysteminterface.h>
#include <qquickitem.h>
#include <QtGui/QScreen>
QT_BEGIN_NAMESPACE
QQuickMenuPopupWindow::QQuickMenuPopupWindow(QWindow *parent) :
- QQuickWindow(parent), m_mouseMoved(false), m_itemAt(0),
- m_parentItem(0), m_menuContentItem(0)
+ QQuickWindow(parent), m_mouseMoved(false), m_needsActivatedEvent(true),
+ m_itemAt(0), m_parentItem(0), m_menuContentItem(0)
{
setFlags(Qt::Popup);
setModality(Qt::WindowModal);
@@ -235,4 +236,27 @@ void QQuickMenuPopupWindow::forwardEventToTransientParent(QMouseEvent *e)
}
}
+void QQuickMenuPopupWindow::exposeEvent(QExposeEvent *e)
+{
+ if (isExposed() && m_needsActivatedEvent) {
+ m_needsActivatedEvent = false;
+ QWindowSystemInterface::handleWindowActivated(this, Qt::PopupFocusReason);
+ } else if (!isExposed() && !m_needsActivatedEvent) {
+ m_needsActivatedEvent = true;
+ if (QWindow *tp = transientParent())
+ QWindowSystemInterface::handleWindowActivated(tp, Qt::PopupFocusReason);
+ }
+ QQuickWindow::exposeEvent(e);
+}
+
+void QQuickMenuPopupWindow::hideEvent(QHideEvent *e)
+{
+ if (QWindow *tp = !m_needsActivatedEvent ? transientParent() : 0) {
+ m_needsActivatedEvent = true;
+ QWindowSystemInterface::handleWindowActivated(tp, Qt::PopupFocusReason);
+ }
+
+ QQuickWindow::hideEvent(e);
+}
+
QT_END_NAMESPACE