Field/area: insertAtCursor() when restoring text
Instead of assigning to `text` directly, which kills editing history and has worse performance.
This commit is contained in:
parent
2545ba6c00
commit
82bcc29475
|
@ -89,10 +89,7 @@ TextArea {
|
|||
previousDefaultText = previousDefaultText
|
||||
|
||||
// Set it only on component creation to avoid binding loops
|
||||
if (! text) {
|
||||
text = window.getState(this, "text", "")
|
||||
cursorPosition = text.length
|
||||
}
|
||||
if (! text) insertAtCursor(window.getState(this, "text", ""))
|
||||
}
|
||||
|
||||
onTextChanged: window.saveState(this)
|
||||
|
|
|
@ -29,7 +29,14 @@ TextField {
|
|||
|
||||
property string previousDefaultText: "" // private
|
||||
|
||||
function reset() { clear(); text = Qt.binding(() => defaultText || "")}
|
||||
function reset() {
|
||||
clear()
|
||||
text = Qt.binding(() => defaultText || "")
|
||||
}
|
||||
|
||||
function insertAtCursor(text) {
|
||||
insert(cursorPosition, text)
|
||||
}
|
||||
|
||||
|
||||
text: defaultText || ""
|
||||
|
@ -69,10 +76,7 @@ TextField {
|
|||
previousDefaultText = previousDefaultText
|
||||
|
||||
// Set it only on component creation to avoid binding loops
|
||||
if (! text) {
|
||||
text = window.getState(this, "text", "")
|
||||
cursorPosition = text.length
|
||||
}
|
||||
if (! text) insertAtCursor(window.getState(this, "text", ""))
|
||||
}
|
||||
|
||||
onTextChanged: window.saveState(this)
|
||||
|
|
Loading…
Reference in New Issue
Block a user