2023-07-17 10:49:06 +02:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Controls.Material
|
2023-05-01 16:59:40 +02:00
|
|
|
|
|
|
|
|
Pane {
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
property string key
|
2023-05-02 13:03:13 +02:00
|
|
|
property int keycode: -1
|
|
|
|
|
|
2023-05-01 16:59:40 +02:00
|
|
|
property QtObject kbd
|
|
|
|
|
padding: 1
|
|
|
|
|
|
2023-05-02 13:03:13 +02:00
|
|
|
function emitKeyEvent() {
|
|
|
|
|
if (keycode == -1) {
|
|
|
|
|
keycode = parseInt(key, 36) - 9 + 0x40 // map a-z char to key code
|
|
|
|
|
}
|
|
|
|
|
kbd.keyEvent(keycode, key)
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-01 16:59:40 +02:00
|
|
|
FlatButton {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
focusPolicy: Qt.NoFocus
|
|
|
|
|
autoRepeat: true
|
|
|
|
|
autoRepeatDelay: 750
|
|
|
|
|
|
|
|
|
|
padding: 0
|
|
|
|
|
|
|
|
|
|
onClicked: {
|
2023-05-02 13:03:13 +02:00
|
|
|
emitKeyEvent()
|
2023-05-01 16:59:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// send keyevent again, otherwise it is ignored
|
|
|
|
|
onDoubleClicked: {
|
2023-05-02 13:03:13 +02:00
|
|
|
emitKeyEvent()
|
2023-05-01 16:59:40 +02:00
|
|
|
}
|
2023-10-13 13:42:16 +02:00
|
|
|
|
|
|
|
|
Label {
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
text: key
|
|
|
|
|
font.pixelSize: Math.max(root.height * 0.67, constants.fontSizeSmall)
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
}
|
2023-05-01 16:59:40 +02:00
|
|
|
}
|
|
|
|
|
}
|