47 lines
854 B
QML
47 lines
854 B
QML
// 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 || '' }
|
|
|
|
elide: Text.ElideRight
|
|
|
|
Popup {
|
|
id: popup
|
|
|
|
width: parent.width
|
|
padding: 0
|
|
|
|
onOpened: {
|
|
input.text = value
|
|
input.forceActiveFocus()
|
|
}
|
|
|
|
TextInput {
|
|
id: input
|
|
|
|
anchors { fill: parent; leftMargin: 2; rightMargin: 2 }
|
|
padding: 0
|
|
clip: true
|
|
|
|
onAccepted: {
|
|
value = input.text.trim()
|
|
popup.close()
|
|
}
|
|
}
|
|
}
|
|
}
|