aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquicktaphandler.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-03-02 20:54:23 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2017-03-07 12:24:47 +0000
commit2f204d3e6a4e5107e09e9b87b841fe91bb6743ac (patch)
tree238bd567dce138ae538fa342f1c981d389a2ec94 /src/quick/handlers/qquicktaphandler.cpp
parent8c659c6c723e4f5f97f46a4555a4765e85c26f1d (diff)
TapHandler: grab before emitting on press, after emitting on release
The issue was that in an onTapped handler, the position property would be wrong and active would be false, because setActive(false) occurred too early. Change-Id: I71b43da703aa2f007a367c239d2ded64e6e7e850 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/handlers/qquicktaphandler.cpp')
-rw-r--r--src/quick/handlers/qquicktaphandler.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp
index 5ee415d710..fbbc6f1c7d 100644
--- a/src/quick/handlers/qquicktaphandler.cpp
+++ b/src/quick/handlers/qquicktaphandler.cpp
@@ -254,10 +254,13 @@ void QQuickTapHandler::setPressed(bool press, bool cancel, QQuickEventPoint *poi
m_longPressTimer.stop();
m_holdTimer.invalidate();
}
- if (m_gesturePolicy == DragThreshold)
- setPassiveGrab(point, press);
- else
- setExclusiveGrab(point, press);
+ if (press) {
+ // on press, grab before emitting changed signals
+ if (m_gesturePolicy == DragThreshold)
+ setPassiveGrab(point, press);
+ else
+ setExclusiveGrab(point, press);
+ }
if (!cancel && !press && point->timeHeld() < longPressThreshold()) {
// Assuming here that pointerEvent()->timestamp() is in ms.
qreal ts = point->pointerEvent()->timestamp() / 1000.0;
@@ -274,6 +277,13 @@ void QQuickTapHandler::setPressed(bool press, bool cancel, QQuickEventPoint *poi
m_lastTapPos = point->scenePos();
}
emit pressedChanged();
+ if (!press) {
+ // on release, ungrab after emitting changed signals
+ if (m_gesturePolicy == DragThreshold)
+ setPassiveGrab(point, press);
+ else
+ setExclusiveGrab(point, press);
+ }
}
}