Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.8.0
-
None
-
QtQuick 2 Material
Qt 5.8
-
e1ae67cb2b9daa9bbbc9f87c8af03f3810022774
Description
Scenario:
Using a TextField / TextArea from the QtQuick.Controls.Material style and controlling the readOnly flag manually:
ApplicationWindow { visible: true width: 640 height: 480 MouseArea { /* Helper to steal focus from TextField */ anchors.fill: parent onClicked: focus = true; } TextField { text: "ChangeMe" readOnly: true onPressAndHold: { readOnly = false selectAll() forceActiveFocus() } onEditingFinished: { readOnly = true } } }
Such that:
- On press-and-hold editing is possible.
- On click, field has active focus (no cursor should be visible)
On first click to focus, no cursor is visible (as expected).
But after the press-and-hold action, losing focus, and regaining focus again, the cursor is visible (while readOnly is true).
This is a bug only persistent in the Material style for the TextField and TextArea.
A possible fix is to take the readonly state (&& !control.readOnly) into account for the cursorDelegate its visible property:
cursorDelegate: Rectangle { ... visible: control.activeFocus && control.selectionStart === control.selectionEnd ... }
to
cursorDelegate: Rectangle { ... visible: control.activeFocus && !control.readOnly && control.selectionStart === control.selectionEnd ... }