summaryrefslogtreecommitdiff
path: root/Fields/TextArea.qml
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.si>2021-06-14 19:09:53 +0200
committerTimotej Lazar <timotej.lazar@araneo.si>2021-06-14 19:13:14 +0200
commit8d57bfb1aef3b71557bc408154ee028751fd688e (patch)
tree22ee6eaa22a3cfc7dfd4f938be16a6e28d7eaf1f /Fields/TextArea.qml
First commit
There was history before but now there is no more.
Diffstat (limited to 'Fields/TextArea.qml')
-rw-r--r--Fields/TextArea.qml54
1 files changed, 54 insertions, 0 deletions
diff --git a/Fields/TextArea.qml b/Fields/TextArea.qml
new file mode 100644
index 0000000..20cfeff
--- /dev/null
+++ b/Fields/TextArea.qml
@@ -0,0 +1,54 @@
+// 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 || '').trim() }
+
+ wrapMode: Text.Wrap
+
+ Popup {
+ id: popup
+
+ width: control.width
+ height: input.height
+ padding: 0
+
+ onOpened: {
+ input.text = value
+ input.forceActiveFocus()
+ }
+
+ TextArea {
+ id: input
+
+ padding: 2
+ topPadding: 0
+ bottomPadding: 0
+ width: parent.width
+ wrapMode: TextEdit.Wrap
+
+ Keys.onPressed: {
+ if (event.modifiers === Qt.NoModifier) {
+ if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
+ value = input.text.trim()
+ popup.close()
+ }
+ }
+ }
+ }
+ }
+}