diff options
Diffstat (limited to 'tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp')
-rw-r--r-- | tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp index 63d3e76..ce5ef57 100644 --- a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp +++ b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp @@ -57,8 +57,16 @@ QGesture* MousePanGestureRecognizer::createGesture(QObject *) QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event) { QPanGesture *g = static_cast<QPanGesture *>(state); + if (event->type() == QEvent::TouchBegin) { + // ignore the following mousepress event + g->setProperty("ignoreMousePress", QVariant::fromValue<bool>(true)); + } else if (event->type() == QEvent::TouchEnd) { + g->setProperty("ignoreMousePress", QVariant::fromValue<bool>(false)); + } QMouseEvent *me = static_cast<QMouseEvent *>(event); - if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick) { + if (event->type() == QEvent::MouseButtonPress) { + if (g->property("ignoreMousePress").toBool()) + return QGestureRecognizer::Ignore; g->setHotSpot(me->globalPos()); g->setProperty("lastPos", me->globalPos()); g->setProperty("pressed", QVariant::fromValue<bool>(true)); @@ -76,7 +84,8 @@ QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *stat } return QGestureRecognizer::NotGesture; } else if (event->type() == QEvent::MouseButtonRelease) { - return QGestureRecognizer::GestureFinished | QGestureRecognizer::ConsumeEventHint; + if (g->property("pressed").toBool()) + return QGestureRecognizer::GestureFinished | QGestureRecognizer::ConsumeEventHint; } return QGestureRecognizer::Ignore; } @@ -90,5 +99,6 @@ void MousePanGestureRecognizer::reset(QGesture *state) g->setAcceleration(0); g->setProperty("lastPos", QVariant()); g->setProperty("pressed", QVariant::fromValue<bool>(false)); + g->setProperty("ignoreMousePress", QVariant::fromValue<bool>(false)); QGestureRecognizer::reset(state); } |