From 8d57bfb1aef3b71557bc408154ee028751fd688e Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 14 Jun 2021 19:09:53 +0200 Subject: First commit There was history before but now there is no more. --- Fields/Text.qml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Fields/Text.qml (limited to 'Fields/Text.qml') diff --git a/Fields/Text.qml b/Fields/Text.qml new file mode 100644 index 0000000..49d7ad2 --- /dev/null +++ b/Fields/Text.qml @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: Unlicense + +import QtQuick 2.12 +import QtQuick.Controls 2.13 + +Label { + id: control + + property var definition + property alias value: control.text + + Keys.onPressed: { + if (event.text === definition.key) { + popup.open() + event.accepted = true + } + } + + function set(val) { value = val || '' } + + elide: Text.ElideRight + + Popup { + id: popup + + width: control.width + height: control.height + padding: 0 + + onOpened: { + input.text = value + input.forceActiveFocus() + } + + TextInput { + id: input + + clip: true + padding: 2 + topPadding: 0 + bottomPadding: 0 + width: parent.width + + onAccepted: { + value = input.text.trim() + popup.close() + } + } + } +} -- cgit v1.3