-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11_keyboard_input.qml
70 lines (57 loc) · 1.49 KB
/
11_keyboard_input.qml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Rectangle {
width: 200; height: 112; color: "lightblue"
TextInput {
anchors.left: parent.left; y: 16
anchors.right: parent.right
text: "Field 1"; font.pixelSize: 32
color: activeFocus ? "black" : "gray"
focus: true
activeFocusOnTab: true\
// onActiveFocusChanged: () => console.log("1 has active focus?", activeFocus)
}
TextInput {
anchors.left: parent.left; y: 64
anchors.right: parent.right
text: "Field 2"; font.pixelSize: 32
color: activeFocus ? "black" : "gray"
activeFocusOnTab: true
// onActiveFocusChanged: () => console.log("2 has active focus?", activeFocus)
}
}
Rectangle {
width: 400; height: 200; color: "black"
Rectangle {
id: leftRect
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 25
}
width: 150; height: 150
color: activeFocus ? "red" : "darkred"
KeyNavigation.right: rightRect
focus: true
}
Rectangle {
id: rightRect
anchors {
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: 25
}
width: 150; height: 150
color: activeFocus ? "#00ff00" : "#008800"
KeyNavigation.left: leftRect
}
}
Rectangle {
width: 400; height: 400; color: "#00a3fc"
focus: true
Image {
id: rocket
anchors.centerIn: parent
source: "rocket.png"
}
Keys.onLeftPressed: () => rocket.rotation = (rocket.rotation - 10) % 360
Keys.onRightPressed: () => rocket.rotation = (rocket.rotation + 10) % 360
}