aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2021-09-07 16:54:44 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-09-08 18:35:14 +0000
commit1a29e946ee809ab32ee508a6823c4ec3ca668b34 (patch)
tree3162cc676c525095566be79c0affadb0a496560e /tests
parentcc0210ade262582534958efd2618a7f312afc604 (diff)
Add button argument to the TapHandler.[single|double|]tapped signals
It would be better to emit the whole pointer event (by pointer because it's non-copyable, or make it copyable and emit by value), but we can't. So we just add the button being tapped; more information is available from the eventpoint argument and TapHandler's point property. To avoid name clashes with anything that's already called "button" in anyone's QML (which is quite likely, actually), the new signal argument is unnamed, so that users will be required to write a function signature that gives it a name rather than relying on context injection. [ChangeLog][QtQuick][Event Handlers] TapHandler's tapped(), singleTapped() and doubleTapped() signals now have two arguments: the QEventPoint instance, and the button being tapped. If you need it, you should write an explicit function for the signal handler: onTapped: function(point, button) { ... } or onDoubleTapped: (point, button)=> ... Fixes: QTBUG-91350 Task-number: QTBUG-64847 Change-Id: I6d25300cbfceb56f27452eac4b29b66bd1b2a41a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 5864644ac8bc3c561696ffef5d033b1cab7d950f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp4
-rw-r--r--tests/manual/pointer/tapHandler.qml9
2 files changed, 7 insertions, 6 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
index 9b1101eb3a..67583fae30 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
@@ -739,8 +739,8 @@ void tst_TapHandler::rightLongPressIgnoreWheel()
QQuickTapHandler *tap = window->rootObject()->findChild<QQuickTapHandler*>();
QVERIFY(tap);
- QSignalSpy tappedSpy(tap, SIGNAL(tapped(QEventPoint *)));
- QSignalSpy longPressedSpy(tap, SIGNAL(longPressed()));
+ QSignalSpy tappedSpy(tap, &QQuickTapHandler::tapped);
+ QSignalSpy longPressedSpy(tap, &QQuickTapHandler::longPressed);
QPoint p1(100, 100);
// Mouse wheel with ScrollBegin phase (because as soon as two fingers are touching
diff --git a/tests/manual/pointer/tapHandler.qml b/tests/manual/pointer/tapHandler.qml
index 6e51fc6fda..c25ea9eb4e 100644
--- a/tests/manual/pointer/tapHandler.qml
+++ b/tests/manual/pointer/tapHandler.qml
@@ -53,14 +53,15 @@ Item {
borderBlink.blinkColor = "red"
borderBlink.start()
}
- onTapped: { // 'eventPoint' is a signal parameter of type QEventPoint*
- console.log("tapped button " + eventPoint.event.button + " @ " + eventPoint.scenePosition +
- " on device '" + eventPoint.event.device.name + "' " + (tapCount > 1 ? (tapCount + " times") : "for the first time"))
+ onTapped: function(point, button) {
+ console.log("tapped button " + button + " @ " + point.scenePosition +
+ " on device '" + point.device.name + "' with modifiers " + handler.point.modifiers +
+ " " + (tapCount > 1 ? (tapCount + " times") : "for the first time"))
if (tapCount > 1) {
tapCountLabel.text = tapCount
flashAnimation.start()
} else {
- borderBlink.tapFeedback(eventPoint.event.button)
+ borderBlink.tapFeedback(button)
}
}
onLongPressed: longPressFeedback.createObject(rect,