diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-07-03 17:17:53 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-07-05 15:02:56 +0200 |
commit | 9b01e2e5d4b38533f02ba9ba907505e8c341cd0a (patch) | |
tree | b3496394653d369abfd41a45f3a084c11f77c377 /tests | |
parent | 42e403a51da3539cc5062fde13884678dba55b5a (diff) |
TapHandler: wait until after tapped is emitted to reset point.position
We don't want it to hold its position indefinitely after the button is
released. But in practice, reset() gets called again anyway in
QQuickSinglePointHandler::handlePointerEventImpl(), _after_
handleEventPoint(), which means after tapped() is emitted. Having the
point hold its position that much longer is convenient for applications
and more consistent with the state expressed by the release event.
Also amend the documentation.
Partially reverts 17237efaefabe924599abe00e92d8b54032d7915
[ChangeLog][Event Handlers][Important Behavior Changes] TapHandler.point now
holds the release position while the tapped() signal is emitted.
Fixes: QTBUG-76871
Task-number: QTBUG-64847
Change-Id: I621a2eba4507a498788e9384344e8b4b7da32403
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml | 2 | ||||
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml index 221e7df139..042b730799 100644 --- a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml +++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml @@ -34,6 +34,7 @@ Rectangle { property alias pressed: tap.pressed property bool checked: false property alias gesturePolicy: tap.gesturePolicy + property point tappedPosition: Qt.point(0, 0) signal tapped signal canceled @@ -51,6 +52,7 @@ Rectangle { longPressThreshold: 100 // CI can be insanely slow, so don't demand a timely release to generate onTapped onTapped: { tapFlash.start() + root.tappedPosition = point.scenePosition root.tapped() } onCanceled: root.canceled() diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp index 33cea69147..e77ea97518 100644 --- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp @@ -107,6 +107,8 @@ void tst_TapHandler::touchGesturePolicyDragThreshold() QQuickItem *buttonDragThreshold = window->rootObject()->findChild<QQuickItem*>("DragThreshold"); QVERIFY(buttonDragThreshold); + QQuickTapHandler *tapHandler = buttonDragThreshold->findChild<QQuickTapHandler*>(); + QVERIFY(tapHandler); QSignalSpy dragThresholdTappedSpy(buttonDragThreshold, SIGNAL(tapped())); // DragThreshold button stays pressed while touchpoint stays within dragThreshold, emits tapped on release @@ -122,6 +124,8 @@ void tst_TapHandler::touchGesturePolicyDragThreshold() QQuickTouchUtils::flush(window); QTRY_VERIFY(!buttonDragThreshold->property("pressed").toBool()); QCOMPARE(dragThresholdTappedSpy.count(), 1); + QCOMPARE(buttonDragThreshold->property("tappedPosition").toPoint(), p1); + QCOMPARE(tapHandler->point().position(), QPointF()); // DragThreshold button is no longer pressed if touchpoint goes beyond dragThreshold dragThresholdTappedSpy.clear(); @@ -152,6 +156,8 @@ void tst_TapHandler::mouseGesturePolicyDragThreshold() QQuickItem *buttonDragThreshold = window->rootObject()->findChild<QQuickItem*>("DragThreshold"); QVERIFY(buttonDragThreshold); + QQuickTapHandler *tapHandler = buttonDragThreshold->findChild<QQuickTapHandler*>(); + QVERIFY(tapHandler); QSignalSpy dragThresholdTappedSpy(buttonDragThreshold, SIGNAL(tapped())); // DragThreshold button stays pressed while mouse stays within dragThreshold, emits tapped on release @@ -164,6 +170,8 @@ void tst_TapHandler::mouseGesturePolicyDragThreshold() QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1); QTRY_VERIFY(!buttonDragThreshold->property("pressed").toBool()); QTRY_COMPARE(dragThresholdTappedSpy.count(), 1); + QCOMPARE(buttonDragThreshold->property("tappedPosition").toPoint(), p1); + QCOMPARE(tapHandler->point().position(), QPointF()); // DragThreshold button is no longer pressed if mouse goes beyond dragThreshold dragThresholdTappedSpy.clear(); |