diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-10-06 17:50:17 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-10-19 06:02:33 +0200 |
commit | d3f2c6ac4205bbe5a1c7174965dbce6f90972be3 (patch) | |
tree | 43e0d33c99ada0b0a11b8b61401eda4a18ad845b /examples/quick | |
parent | e3343eb83f212ea8dea2f2b31859ac39c775f4ba (diff) |
Add TapHandler.exclusiveSignals to enable single/double tap exclusivity
If exclusiveSignals == NotExclusive (the default), behavior remains as
it was: singleTapped() and doubleTapped() are emitted as the taps occur,
so it's not very useful to react on singleTapped() if you mean to
distinguish these two cases.
If exclusiveSignals == SingleTap, the doubleTapped signal will not be
emitted at all, and therefore singleTapped can be emitted immediately
and unambiguously.
If exclusiveSignals == DoubleTap, the singleTapped signal will not be
emitted at all, and therefore doubleTapped can be emitted immediately
and unambiguously.
If exclusiveSignals == SingleTap | DoubleTap, we must wait
qApp->styleHints()->mouseDoubleClickInterval() milliseconds after a tap
is detected before emitting either signal, so that they are distinct and
can be used to drive behavior that should not occur in other cases.
A triple-tap will not trigger either signal.
[ChangeLog][QtQuick][Event Handlers] TapHandler.exclusiveSignals now
lets you make the singleTapped and doubleTapped signals exclusive.
Task-number: QTBUG-65088
Fixes: QTBUG-107264
Change-Id: Ifb2c4b72759246c64b3bfa2f776c28266806b985
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Diffstat (limited to 'examples/quick')
-rw-r--r-- | examples/quick/pointerhandlers/components/Button.qml | 3 | ||||
-rw-r--r-- | examples/quick/pointerhandlers/multibuttons.qml | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/examples/quick/pointerhandlers/components/Button.qml b/examples/quick/pointerhandlers/components/Button.qml index 879e24f5f8..4943f9cb94 100644 --- a/examples/quick/pointerhandlers/components/Button.qml +++ b/examples/quick/pointerhandlers/components/Button.qml @@ -11,6 +11,7 @@ Rectangle { property alias hovered: hoverHandler.hovered property alias gesturePolicy: tap.gesturePolicy property alias margin: tap.margin + property alias exclusiveSignals: tap.exclusiveSignals signal tapped implicitHeight: Math.max(Screen.pixelDensity * 7, label.implicitHeight * 2) @@ -29,7 +30,7 @@ Rectangle { id: tap margin: 10 // the user can tap a little beyond the edges objectName: label.text + " Tap" - onTapped: { + onSingleTapped: { tapFlash.start() root.tapped() } diff --git a/examples/quick/pointerhandlers/multibuttons.qml b/examples/quick/pointerhandlers/multibuttons.qml index 422065cc42..29657f10ea 100644 --- a/examples/quick/pointerhandlers/multibuttons.qml +++ b/examples/quick/pointerhandlers/multibuttons.qml @@ -30,6 +30,7 @@ Item { text: "Launch Missile" Layout.fillWidth: true gesturePolicy: TapHandler.ReleaseWithinBounds + exclusiveSignals: TapHandler.SingleTap onTapped: missileEmitter.burst(1) Text { anchors { top: parent.bottom; horizontalCenter: parent.horizontalCenter } |