aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/snippets/pointerHandlers/tapHandlerGrabChanged.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/doc/snippets/pointerHandlers/tapHandlerGrabChanged.qml')
-rw-r--r--src/quick/doc/snippets/pointerHandlers/tapHandlerGrabChanged.qml46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/quick/doc/snippets/pointerHandlers/tapHandlerGrabChanged.qml b/src/quick/doc/snippets/pointerHandlers/tapHandlerGrabChanged.qml
new file mode 100644
index 0000000000..73631d3551
--- /dev/null
+++ b/src/quick/doc/snippets/pointerHandlers/tapHandlerGrabChanged.qml
@@ -0,0 +1,46 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+import QtQuick
+
+Rectangle {
+ width: 100
+ height: 100
+
+ //![0]
+ TapHandler {
+ gesturePolicy: TapHandler.ReleaseWithinBounds // exclusive grab on press
+ onGrabChanged:
+ (transition, eventPoint) => {
+ switch (transition) {
+ case PointerDevice.GrabExclusive:
+ console.log("took exclusive grab of point", eventPoint.id,
+ "on", eventPoint.device.name)
+ break
+ case PointerDevice.UngrabExclusive:
+ console.log("gave up exclusive grab of point", eventPoint.id,
+ "on", eventPoint.device.name)
+ break
+ case PointerDevice.CancelGrabExclusive:
+ console.log("exclusive grab of point", eventPoint.id,
+ "on", eventPoint.device.name, "has been cancelled")
+ break
+ }
+
+ switch (eventPoint.state) {
+ case EventPoint.Pressed:
+ console.log("on press @", eventPoint.position);
+ break
+ case EventPoint.Updated:
+ console.log("on update @", eventPoint.position);
+ break
+ case EventPoint.Released:
+ console.log("on release @", eventPoint.position);
+ break
+ default:
+ console.log(eventPoint.position, "state", eventPoint.state)
+ break
+ }
+ }
+ }
+ //![0]
+}