diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2023-02-20 10:25:33 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2023-03-02 06:18:57 +0100 |
commit | a6e196ce9cd327df53ef9b9db3020f7775ee1754 (patch) | |
tree | 5ada9737daacfb4fe26aaf57c3f0891ee83fdc4d /src/quick/doc/snippets/pointerHandlers/tapHandlerButtonReleaseWithinBounds.qml | |
parent | 69fa61a11f4689246e8d5ce8edfbeae41dfa08b2 (diff) |
doc: Add snippets and animations illustrating TapHandler.GesturePolicy
People are constantly confused by GesturePolicy and its default value,
so we really need a "glanceable" reference in the docs to show the
differences between use cases.
Also clarify the pitfalls with the default DragThreshold value.
We switch from the \value tag to a 2-column \table because the \image
would otherwise break the table, and also because it saves space and
acts as a meaningful reminder to have the animation right under the
enum value that is being documented.
Pick-to: 6.5 6.4 6.2
Task-number: QTBUG-70397
Task-number: QTBUG-73262
Task-number: QTBUG-100534
Task-number: QTBUG-107239
Task-number: QTBUG-111310
Change-Id: I1ff45f58a8a8edf55f4a8696d881aa9e0bedcfe3
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Diffstat (limited to 'src/quick/doc/snippets/pointerHandlers/tapHandlerButtonReleaseWithinBounds.qml')
-rw-r--r-- | src/quick/doc/snippets/pointerHandlers/tapHandlerButtonReleaseWithinBounds.qml | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/quick/doc/snippets/pointerHandlers/tapHandlerButtonReleaseWithinBounds.qml b/src/quick/doc/snippets/pointerHandlers/tapHandlerButtonReleaseWithinBounds.qml new file mode 100644 index 0000000000..3e8634a605 --- /dev/null +++ b/src/quick/doc/snippets/pointerHandlers/tapHandlerButtonReleaseWithinBounds.qml @@ -0,0 +1,51 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +//![0] +import QtQuick + +Item { + width: 120; height: 80 + + component Button : Rectangle { + id: button + signal clicked + property alias text: buttonLabel.text + + width: 80 + height: 40 + radius: 3 + property color dark: Qt.darker(palette.button, 1.3) + gradient: Gradient { + GradientStop { position: 0.0; color: tapHandler.pressed ? dark : palette.button } + GradientStop { position: 1.0; color: dark } + } + + SequentialAnimation on border.width { + id: tapFlash + running: false + loops: 3 + PropertyAction { value: 2 } + PauseAnimation { duration: 100 } + PropertyAction { value: 0 } + PauseAnimation { duration: 100 } + } + + //![1] + TapHandler { + id: tapHandler + gesturePolicy: TapHandler.ReleaseWithinBounds + onTapped: tapFlash.start() + } + //![1] + + Text { + id: buttonLabel + text: "Click Me" + color: palette.buttonText + anchors.centerIn: parent + } + } + + Button { x: 10; y: 10 } +} +//![0] |