make inplaceedittext work on focus lost

This commit is contained in:
erinn 2019-03-20 14:05:34 -07:00
parent 8b30638373
commit 5ac792826a
1 changed files with 14 additions and 4 deletions

View File

@ -49,13 +49,23 @@ ColumnLayout {
font.pixelSize: lbl.font.pixelSize
horizontalAlignment: Text.AlignHCenter
onActiveFocusChanged: {
if (!activeFocus) {
save()
}
}
Keys.onReturnPressed: {
if (event.modifiers == Qt.NoModifier) {
root.text = txt.text
txt.visible = false
lbl.visible = true
root.updated(txt.text)
save()
}
}
function save() {
root.text = txt.text
txt.visible = false
lbl.visible = true
root.updated(txt.text)
}
}
}