aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickcontrol.cpp
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-02-07 11:33:50 +0100
committerAndy Shaw <andy.shaw@qt.io>2020-02-07 15:30:12 +0100
commit025f938c1b4676782674d54375e1e4e560e4b6cd (patch)
tree9dc4d3ec2c181caf987e9c7d80e3dffca2cf8c77 /src/quicktemplates2/qquickcontrol.cpp
parentb10912ba731144e8c41cbfa35fb1553ad04b2b88 (diff)
Account for when a touch event is synthesized by Qt as a mouse event
When a control is on a Flickable with a pressDelay then any press events sent from a touch device will be replayed as mouse events due to the delay. As a result we cannot depend on the fact that we got the first press as a touch event when checking if the id matches before accepting it. So we need to keep the previous pos when it is a synthesized mouse event so we can ensure the release is also accepted. Fixes: QTBUG-77202 Change-Id: I6f5d8506bd803daf834093e8fd412504150c4ca6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickcontrol.cpp')
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index 7e249dae..838a841d 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -178,6 +178,12 @@ bool QQuickControlPrivate::acceptTouch(const QTouchEvent::TouchPoint &point)
return true;
}
+ // If the control is on a Flickable that has a pressDelay, then the press is never
+ // sent as a touch event, therefore we need to check for this case.
+ if (touchId == -1 && pressWasTouch && point.state() == Qt::TouchPointReleased &&
+ point.pos() == previousPressPos) {
+ return true;
+ }
return false;
}
#endif
@@ -213,6 +219,8 @@ void QQuickControlPrivate::handleRelease(const QPointF &)
if ((focusPolicy & Qt::ClickFocus) == Qt::ClickFocus && QGuiApplication::styleHints()->setFocusOnTouchRelease())
setActiveFocus(q, Qt::MouseFocusReason);
touchId = -1;
+ pressWasTouch = false;
+ previousPressPos = QPointF();
}
void QQuickControlPrivate::handleUngrab()
@@ -2103,6 +2111,10 @@ void QQuickControl::mousePressEvent(QMouseEvent *event)
{
Q_D(QQuickControl);
d->handlePress(event->localPos());
+ if (event->source() == Qt::MouseEventSynthesizedByQt) {
+ d->pressWasTouch = true;
+ d->previousPressPos = event->localPos();
+ }
event->accept();
}