From 5ac792826a3881c0b512fe21ff030363ac559874 Mon Sep 17 00:00:00 2001 From: erinn Date: Wed, 20 Mar 2019 14:05:34 -0700 Subject: [PATCH] make inplaceedittext work on focus lost --- qml/widgets/InplaceEditText.qml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/qml/widgets/InplaceEditText.qml b/qml/widgets/InplaceEditText.qml index 7122603d..ea0403f4 100644 --- a/qml/widgets/InplaceEditText.qml +++ b/qml/widgets/InplaceEditText.qml @@ -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) + } } } \ No newline at end of file