fuzbal/Fields/TextArea.qml

52 lines
1 KiB
QML
Raw Permalink Normal View History

// 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
2021-09-05 16:23:41 +02:00
anchors.fill: parent
padding: 2
wrapMode: TextEdit.Wrap
Keys.onPressed: {
2021-09-05 16:23:41 +02:00
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
if (event.modifiers === Qt.NoModifier) {
value = input.text.trim()
popup.close()
}
}
}
}
}
}