blob: 9b44c3500aa3fe39d0d8f95859e25a97d96deb27 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// SPDX-License-Identifier: Unlicense
import QtQuick 2.12
import QtQuick.Controls 2.13
Label {
id: control
property var model
property alias value: control.text
Keys.onPressed: {
if (event.text === model.key) {
popup.open()
event.accepted = true
}
}
function set(val) { value = (val || '').trim() }
wrapMode: Text.Wrap
Popup {
id: popup
width: parent.width
padding: 0
onOpened: {
input.text = value
input.forceActiveFocus()
}
TextArea {
id: input
anchors.fill: parent
padding: 2
wrapMode: TextEdit.Wrap
Keys.onPressed: {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
if (event.modifiers === Qt.NoModifier) {
value = input.text.trim()
popup.close()
}
}
}
}
}
}
|