Fix field and text area defaultText binding
Break the binding when the field is focused, recreate it when focus is lost, properly recreate it when using reset() function.
This commit is contained in:
parent
a6529b040c
commit
9f51b3c1ca
|
@ -19,7 +19,7 @@ TextArea {
|
|||
property alias backgroundColor: textAreaBackground.color
|
||||
|
||||
|
||||
function reset() { clear(); text = defaultText }
|
||||
function reset() { clear(); text = Qt.binding(() => defaultText) }
|
||||
function insertAtCursor(text) { insert(cursorPosition, text) }
|
||||
|
||||
|
||||
|
@ -52,6 +52,9 @@ TextArea {
|
|||
textArea.cursorPosition = text.length
|
||||
}
|
||||
|
||||
onActiveFocusChanged:
|
||||
text = activeFocus || changed ? text : Qt.binding(() => defaultText)
|
||||
|
||||
onTextChanged: window.saveState(this)
|
||||
|
||||
Keys.onPressed: if (
|
||||
|
|
|
@ -39,6 +39,9 @@ TextField {
|
|||
|
||||
onTextChanged: window.saveState(this)
|
||||
|
||||
onActiveFocusChanged:
|
||||
text = activeFocus || changed ? text : Qt.binding(() => defaultText)
|
||||
|
||||
Keys.onPressed: if (
|
||||
event.modifiers & Qt.AltModifier ||
|
||||
event.modifiers & Qt.MetaModifier
|
||||
|
@ -67,7 +70,7 @@ TextField {
|
|||
readonly property bool changed: text !== defaultText
|
||||
|
||||
|
||||
function reset() { clear(); text = defaultText }
|
||||
function reset() { clear(); text = Qt.binding(() => defaultText)}
|
||||
|
||||
|
||||
Binding on color {
|
||||
|
|
Loading…
Reference in New Issue
Block a user