summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippo Cucchetto <filippocucchetto@gmail.com>2015-08-17 17:10:35 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2016-01-29 11:10:32 +0000
commit4998538c94ed8cb029b8849a60b3f7528eae8311 (patch)
treebba17e65f3142e4645ab0f79c26ab108c26130bb
parenta33fe70970d891e096fff6a84d7e0c02f8ee978a (diff)
downloadqtquickcontrols-4998538c94ed8cb029b8849a60b3f7528eae8311.tar.gz
Fixed key event propagation with submenus
When a menu receive a Key_Right event and its subMenu popupwindow is already visible, the event should be discarded. In this way the event can forwarded up to the menubar for moving to the next root menu. Change-Id: Ifeb402f66fdac9fcf3a541456b929d11d36ad00d Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r--src/controls/MenuBar.qml2
-rw-r--r--src/controls/Private/MenuContentItem.qml6
2 files changed, 7 insertions, 1 deletions
diff --git a/src/controls/MenuBar.qml b/src/controls/MenuBar.qml
index 444185cc..8d49a1ed 100644
--- a/src/controls/MenuBar.qml
+++ b/src/controls/MenuBar.qml
@@ -246,6 +246,8 @@ MenuBarPrivate {
}
}
+ Keys.forwardTo: d.openedMenuIndex !== -1 ? [root.menus[d.openedMenuIndex].__contentItem] : []
+
Row {
id: row
x: d.style ? d.style.padding.left : 0
diff --git a/src/controls/Private/MenuContentItem.qml b/src/controls/Private/MenuContentItem.qml
index a0b346c4..c208e093 100644
--- a/src/controls/Private/MenuContentItem.qml
+++ b/src/controls/Private/MenuContentItem.qml
@@ -138,9 +138,13 @@ Loader {
Keys.onRightPressed: {
var item = content.menuItemAt(__menu.__currentIndex)
- if ((event.accepted = (item && item.styleData.type === MenuItemType.Menu))) {
+ if (item && item.styleData.type === MenuItemType.Menu
+ && !item.__menuItem.__popupVisible) {
item.__showSubMenu(true)
item.__menuItem.__currentIndex = 0
+ event.accepted = true
+ } else {
+ event.accepted = false
}
}