aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/pointer/tapHandler.qml
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-10-18 18:45:49 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2017-02-09 14:32:21 +0000
commitcb78d5c91ed33543a8e7fe7717f74f95834e4cc3 (patch)
tree3de3fbf56055d3aa0dc8017bbd705f9e6325f49c /tests/manual/pointer/tapHandler.qml
parent5c639a07fd90916d39823e800d5d89f779d892e9 (diff)
TapHandler: add gesturePolicy
Until now it behaved as if this was set to DragThreshold: give up on the tap as soon as you are clearly dragging rather than tapping. But that's not what is normally wanted when building a Button control, for example. So provide 3 options: give up past the drag threshold, when the pointer goes outside the bounds, or when it's released outside the bounds. The longPressThreshold also constrains all three cases: holding (or dragging) for too long will not result in an immediate cancellation, but it also will not be a tap gesture. Change-Id: I95aec978e783892b55371391a27642751d91d9ff Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/manual/pointer/tapHandler.qml')
-rw-r--r--tests/manual/pointer/tapHandler.qml29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/manual/pointer/tapHandler.qml b/tests/manual/pointer/tapHandler.qml
index f2a454fb80..2e45b1c369 100644
--- a/tests/manual/pointer/tapHandler.qml
+++ b/tests/manual/pointer/tapHandler.qml
@@ -57,6 +57,9 @@ Item {
acceptedButtons: (leftAllowedCB.checked ? Qt.LeftButton : Qt.NoButton) |
(middleAllowedCB.checked ? Qt.MiddleButton : Qt.NoButton) |
(rightAllowedCB.checked ? Qt.RightButton : Qt.NoButton)
+ gesturePolicy: (policyDragThresholdCB.checked ? TapHandler.DragThreshold :
+ policyWithinBoundsCB.checked ? TapHandler.WithinBounds :
+ TapHandler.ReleaseWithinBounds)
onPressedButtonsChanged: switch (pressedButtons) {
case Qt.MiddleButton: borderBlink.blinkColor = "orange"; break;
case Qt.RightButton: borderBlink.blinkColor = "magenta"; break;
@@ -141,5 +144,31 @@ Item {
id: rightAllowedCB
text: "right click"
}
+ Text { text: " gesture policy:"; anchors.verticalCenter: leftAllowedCB.verticalCenter }
+ Examples.CheckBox {
+ id: policyDragThresholdCB
+ text: "drag threshold"
+ onCheckedChanged: if (checked) {
+ policyWithinBoundsCB.checked = false;
+ policyReleaseWithinBoundsCB.checked = false;
+ }
+ }
+ Examples.CheckBox {
+ id: policyWithinBoundsCB
+ text: "within bounds"
+ onCheckedChanged: if (checked) {
+ policyDragThresholdCB.checked = false;
+ policyReleaseWithinBoundsCB.checked = false;
+ }
+ }
+ Examples.CheckBox {
+ id: policyReleaseWithinBoundsCB
+ checked: true
+ text: "release within bounds"
+ onCheckedChanged: if (checked) {
+ policyDragThresholdCB.checked = false;
+ policyWithinBoundsCB.checked = false;
+ }
+ }
}
}