55 lines
1.1 KiB
QML
55 lines
1.1 KiB
QML
|
// 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()
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|