summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-11-18 15:02:18 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2017-02-09 14:32:10 +0000
commit5c639a07fd90916d39823e800d5d89f779d892e9 (patch)
tree6a42a04f6c9093ec7430b79e577eaa99413ef3c3 /tests/manual
parent3e21962cea50433c8f043d2a8a0d61ef86339a22 (diff)
TapHandler: add long-press feature
Add a longPressed signal, emitted when the point is held long enough. Add the longPressThreshold to control how long that is. Change-Id: I95a65f1e4c62eb41fb9ea02b14bdc3f16aa72ec2 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/pointer/tapHandler.qml19
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/manual/pointer/tapHandler.qml b/tests/manual/pointer/tapHandler.qml
index d099fc7faf..f2a454fb80 100644
--- a/tests/manual/pointer/tapHandler.qml
+++ b/tests/manual/pointer/tapHandler.qml
@@ -57,6 +57,11 @@ Item {
acceptedButtons: (leftAllowedCB.checked ? Qt.LeftButton : Qt.NoButton) |
(middleAllowedCB.checked ? Qt.MiddleButton : Qt.NoButton) |
(rightAllowedCB.checked ? Qt.RightButton : Qt.NoButton)
+ onPressedButtonsChanged: switch (pressedButtons) {
+ case Qt.MiddleButton: borderBlink.blinkColor = "orange"; break;
+ case Qt.RightButton: borderBlink.blinkColor = "magenta"; break;
+ default: borderBlink.blinkColor = "green"; break;
+ }
onCanceled: {
console.log("canceled @ " + pos)
borderBlink.blinkColor = "red"
@@ -68,14 +73,13 @@ Item {
tapCountLabel.text = tapCount
flashAnimation.start()
} else {
- switch (point.event.button) {
- case Qt.LeftButton: borderBlink.blinkColor = "green"; break;
- case Qt.MiddleButton: borderBlink.blinkColor = "orange"; break;
- case Qt.RightButton: borderBlink.blinkColor = "magenta"; break;
- }
borderBlink.start()
}
}
+ onLongPressed: longPressFeedback.createObject(rect,
+ {"x": pos.x, "y": pos.y,
+ "text": "long press",
+ "color": borderBlink.blinkColor})
}
Text {
@@ -105,6 +109,11 @@ Item {
}
}
+ Component {
+ id: longPressFeedback
+ Text { }
+ }
+
SequentialAnimation {
id: borderBlink
property color blinkColor: "blue"