diff options
author | Paul Olav Tvete <paul.tvete@qt.io> | 2017-08-23 11:48:11 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@qt.io> | 2017-09-26 13:38:06 +0000 |
commit | 35781b358887facf954307b0d6c5958ce089eb72 (patch) | |
tree | 75c4517ea1b47136e900a66dd15252fbc6b870c1 /src/widgets/widgets/qmenubar.cpp | |
parent | bc31d2235cbf81c05ef80de723ebc4dc45a89695 (diff) |
Return focus to correct widget after showing menu
By the time we call setKeyboardMode(true), the menu may
already have taken focus. This change sets keyboardFocusWidget
before opening the popup, and makes sure that keyboardFocusWidget
is not set to the popup. (We cannot remove the assignment from
setKeyboardMode(), since it's called from several places.)
[ChangeLog][QtWidgets] Fixed widget losing focus after showing
menu second time.
Task-number: QTBUG-56860
Change-Id: Ic01726bf694e6f365dd7b601ad555156e0fdf6c5
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/widgets/qmenubar.cpp')
-rw-r--r-- | src/widgets/widgets/qmenubar.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 3d24cc0387..41b6bf49f8 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -288,7 +288,7 @@ void QMenuBarPrivate::setKeyboardMode(bool b) keyboardState = b; if(b) { QWidget *fw = QApplication::focusWidget(); - if (fw != q) + if (fw && fw != q && fw->window() != QApplication::activePopupWidget()) keyboardFocusWidget = fw; focusFirstAction(); q->setFocus(Qt::MenuBarFocusReason); @@ -1706,6 +1706,7 @@ void QMenuBarPrivate::_q_internalShortcutActivated(int id) } } + keyboardFocusWidget = QApplication::focusWidget(); setCurrentAction(act, true, true); if (act && !act->menu()) { activateAction(act, QAction::Trigger); |