Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.7
-
None
-
eb6e122c68333382309843ad96e7d04d2c5a3595
Description
Run the application below:
import QtQuick 2.6 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 import QtQuick.Controls 2.0 ApplicationWindow { width: 400 height: 200 visible: true onActiveFocusItemChanged: print("activeFocusItem", activeFocusItem) header: ToolBar { RowLayout { ToolButton { text: qsTr("File") onClicked: fileMenu.open() Menu { id: fileMenu y: parent.height MenuItem { text: qsTr("New") } MenuItem { text: qsTr("open") } MenuItem { text: qsTr("Close") } } } } } FocusScope { id: focusScope focus: true anchors.fill: parent property bool toggled: false onToggledChanged: print("toggled", toggled) Keys.onPressed: { if (event.modifiers === Qt.AltModifier) { focusScope.toggled = true; } } Keys.onReleased: { if ((event.modifiers === Qt.AltModifier || event.key === Qt.Key_Alt) && !event.isAutoRepeat) { focusScope.toggled = false; } } RowLayout { anchors.centerIn: parent Button { id: penButton text: qsTr("Pen") highlighted: !focusScope.toggled } Button { id: eyedropperButton text: qsTr("Eyedropper") highlighted: focusScope.toggled } } } }
The idea is that holding the Alt key down will toggle between two "modes". The mode is indicated by a highlighted button.
Try switching between the buttons. Now open the menu by clicking the "File" button. The menu will receive focus and the focus scope will lose it. If you then close the menu and try to switch between the buttons again, it won't work because the focus scope never regained focus (the root item now has it).
In this thread, Andrew said that restoring focus to the contentItem of ApplicationWindow would make this work, so we should try to do that.
Attachments
Issue Links
- relates to
-
QTBUG-80709 Popups not restoring focus to the children of Window contentItem upon closing
- Reported
For Gerrit Dashboard: QTBUG-53275 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
158667,5 | Popup: restore focus to contentItem of ApplicationWindow when closing | 5.7 | qt/qtquickcontrols2 | Status: MERGED | -2 | 0 |