summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippo Cucchetto <filippocucchetto@gmail.com>2015-12-24 11:03:22 +0100
committerFilippo Cucchetto <filippocucchetto@gmail.com>2016-01-24 15:01:27 +0000
commita33fe70970d891e096fff6a84d7e0c02f8ee978a (patch)
treeaec5af4a46bfe92d8fd4302c921029c9403a045b
parent1836451c18c557dbfc332124ef4645b3ba2bc9d4 (diff)
downloadqtquickcontrols-a33fe70970d891e096fff6a84d7e0c02f8ee978a.tar.gz
Fixed keyboard navigation in submenus
This bug was due to a couple of factors interacting: 1) the QQuickMenu::__popupVisible property is not in sync with the popupWindow::visible property. In fact, the QQuickMenu::__popupVisible becomes true before the PopupWindow::Show() method is called. 2) In the Menu.qml file, the menu content item is created through the user of Loader, whose active property becomes true when the QQuickMenu::__popupVisible property is true. So the result is that the MenuContentItem is created before the QQuickPopupWindow is effectively visible. 3) Given point (2), the MenuContentItem requests focus on creation (since it has focus: true). However, given (1), the QQuickPopupWindow is neither visible nor active. This patch addresses this problem by forcing activeFocus to the menuContentItem only when the popupWindow gets focus. Task-number: QTBUG-41951 Change-Id: I095700726aab4ac45a62cd37b33a069e294df30e Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r--src/controls/qquickmenupopupwindow.cpp7
-rw-r--r--src/controls/qquickmenupopupwindow_p.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/src/controls/qquickmenupopupwindow.cpp b/src/controls/qquickmenupopupwindow.cpp
index 2a91940e..d4ad6795 100644
--- a/src/controls/qquickmenupopupwindow.cpp
+++ b/src/controls/qquickmenupopupwindow.cpp
@@ -148,6 +148,13 @@ void QQuickMenuPopupWindow::updatePosition()
setGeometry(newPos.x(), newPos.y(), width(), height());
}
+void QQuickMenuPopupWindow::focusInEvent(QFocusEvent *e)
+{
+ QQuickWindow::focusInEvent(e);
+ if (m_menu && m_menu->menuContentItem())
+ m_menu->menuContentItem()->forceActiveFocus();
+}
+
void QQuickMenuPopupWindow::exposeEvent(QExposeEvent *e)
{
// the popup will reposition at the last moment, so its
diff --git a/src/controls/qquickmenupopupwindow_p.h b/src/controls/qquickmenupopupwindow_p.h
index 8c10f255..fb96dc74 100644
--- a/src/controls/qquickmenupopupwindow_p.h
+++ b/src/controls/qquickmenupopupwindow_p.h
@@ -68,6 +68,7 @@ Q_SIGNALS:
void willBeDeletedLater();
protected:
+ void focusInEvent(QFocusEvent *);
void exposeEvent(QExposeEvent *);
bool shouldForwardEventAfterDismiss(QMouseEvent *) const;