diff options
Diffstat (limited to 'src/quicktemplates2/qquickcontrol.cpp')
-rw-r--r-- | src/quicktemplates2/qquickcontrol.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index b086f3ee..c039253d 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -145,6 +145,19 @@ QQuickControlPrivate::~QQuickControlPrivate() #endif } +bool QQuickControlPrivate::acceptTouch(const QTouchEvent::TouchPoint &point) +{ + if (point.id() == touchId) + return true; + + if (touchId == -1 && point.state() == Qt::TouchPointPressed) { + touchId = point.id(); + return true; + } + + return false; +} + void QQuickControlPrivate::handlePress(const QPointF &) { Q_Q(QQuickControl); @@ -1348,14 +1361,14 @@ void QQuickControl::touchEvent(QTouchEvent *event) switch (event->type()) { case QEvent::TouchBegin: for (const QTouchEvent::TouchPoint &point : event->touchPoints()) { - if (point.id() == d->touchId) + if (d->acceptTouch(point)) d->handlePress(point.pos()); } break; case QEvent::TouchUpdate: for (const QTouchEvent::TouchPoint &point : event->touchPoints()) { - if (point.id() != d->touchId) + if (!d->acceptTouch(point)) continue; switch (point.state()) { @@ -1376,7 +1389,7 @@ void QQuickControl::touchEvent(QTouchEvent *event) case QEvent::TouchEnd: for (const QTouchEvent::TouchPoint &point : event->touchPoints()) { - if (point.id() == d->touchId) + if (d->acceptTouch(point)) d->handleRelease(point.pos()); } break; |