Details
-
Bug
-
Resolution: Invalid
-
P4: Low
-
None
-
5.7.0
-
Desktop Linux
Description
- Please run the following code:
import QtQuick 2.3 import QtQuick.Window 2.2 Window { visible: true width: 500 height: 500 MouseArea { anchors.fill: parent onPressed: { console.warn("mouse is pressed") rect3.enabled = false; rect3.forceActiveFocus(); } onReleased: { console.warn("mouse is released") } onPressAndHold: { console.warn("mouse is pressAndHold") rect3.enabled = true; } } Rectangle { id: rect1 width: 100 height: 100 color: "red" focus: true onFocusChanged: { console.warn("rect1 focus is changed as " + focus); } onActiveFocusChanged: { console.warn("rect1 active focus is changed as " + activeFocus); } Keys.onPressed: { console.warn("key " + event.key + " is pressed at rect1"); } } Rectangle { id: rect2 anchors.left: rect1.right anchors.leftMargin: 50 width: 100 height: 100 color: "blue" onFocusChanged: { console.warn("rect2 focus is changed as " + focus); } onActiveFocusChanged: { console.warn("rect2 active focus is changed as " + activeFocus); } Keys.onPressed: { console.warn("key " + event.key + " is pressed at rect2"); } onEnabledChanged: { console.warn("rect2 enabled is " + enabled); } Rectangle { id: rect3 width: 50 height: 50 color: "black" onFocusChanged: { console.warn("rect3 focus is changed as " + focus); } onActiveFocusChanged: { console.warn("rect3 active focus is changed as " + activeFocus); } Keys.onPressed: { console.warn("key " + event.key + " is pressed at rect3"); } onEnabledChanged: { console.warn("rect3 enabled is " + enabled); } } } }
- Click on the app
- It logs:
qml: rect3 enabled is false qml: rect3 focus is changed as true
Expected behavior is that an item can't get the focus when it is not enabled.
Attachments
For Gerrit Dashboard: QTBUG-55937 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
170787,1 | QQuickItem::setFocus: don't focus if not enabled | 5.6 | qt/qtdeclarative | Status: ABANDONED | -1 | 0 |