blob: 2fdea2da13d60b0058428d02657bbc5d1f843666 (
plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
import Qt 4.7
import Qt.labs.gestures 2.0
Rectangle {
width: parent.width
height: 100
color: "grey"
border.width: 1
property string text
property int tapCounter: 0
property int tapAndHoldCounter: 0
property int swipeCounter: 0
function isHorizontalSwipe(angle) {
if (angle > 150 && angle < 210)
return true;
if (angle > 330 || angle < 30)
return true;
return false;
}
Text {
anchors.fill: parent
id: buttonText
text: "-Tap:" + parent.tapCounter + "\n-TapAndHold:" + parent.tapAndHoldCounter + "\n-Swipe:" + parent.swipeCounter
font.pointSize: 20
}
GestureArea {
anchors.fill: parent
Tap {
when: true
onStarted: {
console.log("--tap started")
}
onUpdated: {
console.log("--tap updated")
}
onFinished: {
console.log("--tap finished")
parent.parent.tapCounter++
}
onCanceled: {
console.log("--tap canceled")
}
}
TapAndHold {
when: true
onStarted: {
console.log("--tapAndHold started")
}
onUpdated: {
console.log("--tapAndHold updated")
}
onFinished: {
console.log("--tapAndHold finished")
parent.parent.tapAndHoldCounter++
}
onCanceled: {
console.log("--tapAndHold canceled")
}
}
Swipe {
when: isHorizontalSwipe(gesture.swipeAngle)
onStarted: {
console.log("--swipe started")
}
onUpdated: {
console.log("--swipe updated")
}
onFinished: {
console.log("--swipe finished:" + gesture.swipeAngle)
parent.parent.swipeCounter++
}
onCanceled: {
console.log("--swipe canceled")
}
}
}
}
|