From aa06a424c5b40d7961a3928e12e59a0aff855675 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 23 Nov 2016 17:14:14 +0100 Subject: SwipeDelegate: fix swipes that begin over a child item of a delegate If the mouse was pressed over a child item of the delegate, the event's position will be for that item, rather than the entire control. To fix this, we need to set the correct pressPoint. To avoid duplicating QQuickAbstractButton::mousePressEvent()'s code, we simply set the correct pressPoint after calling it in QQuickSwipeDelegatePrivate::handleMousePressEvent(). Task-number: QTBUG-57271 Change-Id: I7204d6176c755512eeeb0b1a57a920fbab40392c Reviewed-by: J-P Nurmi --- src/quicktemplates2/qquickswipedelegate.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp index 743f38ff..5430a4de 100644 --- a/src/quicktemplates2/qquickswipedelegate.cpp +++ b/src/quicktemplates2/qquickswipedelegate.cpp @@ -598,6 +598,10 @@ bool QQuickSwipeDelegatePrivate::handleMousePressEvent(QQuickItem *item, QMouseE // events will go through the regular channels (mousePressEvent()) until then. if (qFuzzyIsNull(swipePrivate->position)) { q->mousePressEvent(event); + // The press point could be incorrect if the press happened over a child item, + // so we correct it after calling the base class' mousePressEvent(), rather + // than having to duplicate its code just so we can set the pressPoint. + pressPoint = item->mapToItem(q, event->pos()); return true; } -- cgit v1.2.3