Browse Source

qml: create workaround for spurious textChanged events coming from TextArea. fixes #8280

This commit also fixes a gap, where a seed text change could leave the page valid for the
duration of the valid check delay timer, while the seed is actually invalid.
master
Sander van Grieken 3 years ago
parent
commit
78d79290ad
  1. 13
      electrum/gui/qml/components/controls/SeedTextArea.qml

13
electrum/gui/qml/components/controls/SeedTextArea.qml

@ -10,12 +10,17 @@ Pane {
implicitHeight: rootLayout.height
padding: 0
property string text
property alias readOnly: seedtextarea.readOnly
property alias text: seedtextarea.text
property alias placeholderText: seedtextarea.placeholderText
property var _suggestions: []
onTextChanged: {
if (seedtextarea.text != text)
seedtextarea.text = text
}
background: Rectangle {
color: "transparent"
}
@ -84,6 +89,12 @@ Pane {
}
onTextChanged: {
// work around Qt issue, TextArea fires spurious textChanged events
// NOTE: might be Qt virtual keyboard, or Qt upgrade from 5.15.2 to 5.15.7
if (root.text != text)
root.text = text
// update suggestions
_suggestions = bitcoin.mnemonicsFor(seedtextarea.text.split(' ').pop())
// TODO: cursorPosition only on suggestion apply
cursorPosition = text.length

Loading…
Cancel
Save