From 2f204d3e6a4e5107e09e9b87b841fe91bb6743ac Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 2 Mar 2017 20:54:23 +0100 Subject: TapHandler: grab before emitting on press, after emitting on release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/quick/handlers/qquicktaphandler.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/quick/handlers/qquicktaphandler.cpp') 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); + } } } -- cgit v1.2.3