diff options
-rw-r--r-- | src/gui/widgets/qmenu.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qmenu/tst_qmenu.cpp | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index d8b0c62..400fd30 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -2820,7 +2820,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) key_consumed = true; if(d->scroll) d->scrollMenu(nextAction, QMenuPrivate::QMenuScroller::ScrollCenter, false); - d->setCurrentAction(nextAction, 20, QMenuPrivate::SelectedFromElsewhere, true); + d->setCurrentAction(nextAction, 0, QMenuPrivate::SelectedFromElsewhere, true); if (!nextAction->menu() && activateAction) { d->setSyncAction(); d->activateAction(nextAction, QAction::Trigger); diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 0b513b8..16e6f00 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -111,6 +111,7 @@ private slots: void pushButtonPopulateOnAboutToShow(); void QTBUG7907_submenus_autoselect(); void QTBUG7411_submenus_activate(); + void QTBUG20403_nested_popup_on_shortcut_trigger(); void QTBUG_10735_crashWithDialog(); void QTBUG_25544_macMenuState(); void QTBUG_25544_macMenuActionState(); @@ -983,6 +984,22 @@ void tst_QMenu::QTBUG7411_submenus_activate() QTRY_VERIFY(sub1.isVisible()); } +void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger() +{ + QMenu menu("Test Menu"); + QMenu sub1("&sub1"); + QMenu subsub1("&subsub1"); + subsub1.addAction("foo"); + sub1.addMenu(&subsub1); + menu.addMenu(&sub1); + menu.show(); + QVERIFY(QTest::qWaitForWindowShown(&menu)); + QTest::keyPress(&menu, Qt::Key_S); + QTest::qWait(100); // 20ms delay with previous behavior + QTRY_VERIFY(sub1.isVisible()); + QVERIFY(!subsub1.isVisible()); +} + class MyMenu : public QMenu { Q_OBJECT |