diff options
-rw-r--r-- | src/quick/handlers/qquicktaphandler.cpp | 6 | ||||
-rw-r--r-- | src/quick/handlers/qquicktaphandler_p.h | 6 | ||||
-rw-r--r-- | src/quick/items/qquickevents_p_p.h | 2 | ||||
-rw-r--r-- | tests/manual/pointer/tapHandler.qml | 34 |
4 files changed, 28 insertions, 20 deletions
diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp index 992bc5e438..45240a62ab 100644 --- a/src/quick/handlers/qquicktaphandler.cpp +++ b/src/quick/handlers/qquicktaphandler.cpp @@ -291,12 +291,12 @@ void QQuickTapHandler::setPressed(bool press, bool cancel, QQuickEventPoint *poi else m_tapCount = 1; qCDebug(lcTapHandler) << objectName() << "tapped" << m_tapCount << "times"; - emit tapped(); + emit tapped(point); emit tapCountChanged(); if (m_tapCount == 1) - emit singleTapped(); + emit singleTapped(point); else if (m_tapCount == 2) - emit doubleTapped(); + emit doubleTapped(point); m_lastTapTimestamp = ts; m_lastTapPos = point->scenePosition(); } else { diff --git a/src/quick/handlers/qquicktaphandler_p.h b/src/quick/handlers/qquicktaphandler_p.h index a4c5bf657e..954175f161 100644 --- a/src/quick/handlers/qquicktaphandler_p.h +++ b/src/quick/handlers/qquicktaphandler_p.h @@ -94,9 +94,9 @@ Q_SIGNALS: void timeHeldChanged(); void longPressThresholdChanged(); void gesturePolicyChanged(); - void tapped(); - void singleTapped(); - void doubleTapped(); + void tapped(QQuickEventPoint *eventPoint); + void singleTapped(QQuickEventPoint *eventPoint); + void doubleTapped(QQuickEventPoint *eventPoint); void longPressed(); protected: diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h index c67c386676..7ac2bab7fd 100644 --- a/src/quick/items/qquickevents_p_p.h +++ b/src/quick/items/qquickevents_p_p.h @@ -386,7 +386,7 @@ private: class Q_QUICK_PRIVATE_EXPORT QQuickPointerEvent : public QObject { Q_OBJECT - Q_PROPERTY(const QQuickPointerDevice *device READ device) + Q_PROPERTY(QQuickPointerDevice *device READ device) Q_PROPERTY(Qt::KeyboardModifiers modifiers READ modifiers) Q_PROPERTY(Qt::MouseButtons button READ button) Q_PROPERTY(Qt::MouseButtons buttons READ buttons) diff --git a/tests/manual/pointer/tapHandler.qml b/tests/manual/pointer/tapHandler.qml index 08cf987293..8c1fac9a2f 100644 --- a/tests/manual/pointer/tapHandler.qml +++ b/tests/manual/pointer/tapHandler.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. @@ -53,18 +53,20 @@ Item { borderBlink.blinkColor = "red" borderBlink.start() } - onTapped: { // 'point' is an implicit parameter referencing to a QQuickEventPoint instance + onTapped: { // 'eventPoint' is a signal parameter of type QQuickEventPoint* + console.log("tapped button " + eventPoint.event.button + " @ " + eventPoint.scenePosition + + " on device '" + eventPoint.event.device.name + "' " + (tapCount > 1 ? (tapCount + " times") : "for the first time")) if (tapCount > 1) { tapCountLabel.text = tapCount flashAnimation.start() } else { - borderBlink.start() + borderBlink.tapFeedback(eventPoint.event.button) } } onLongPressed: longPressFeedback.createObject(rect, {"x": point.position.x, "y": point.position.y, - "text": Math.round(handler.timeHeld).toFixed(3) + " sec", - "color": borderBlink.blinkColor}) + "text": handler.timeHeld.toFixed(3) + " sec", + "color": buttonToBlinkColor(point.pressedButtons)}) } Text { @@ -99,7 +101,7 @@ Item { radius: handler.timeHeld * 100 visible: radius > 0 && handler.pressed border.width: 3 - border.color: borderBlink.blinkColor + border.color: buttonToBlinkColor(handler.point.pressedButtons) color: "transparent" width: radius * 2 height: radius * 2 @@ -115,13 +117,11 @@ Item { SequentialAnimation { id: borderBlink - property color blinkColor: (function(pbtns) { - switch (pbtns) { - case Qt.MiddleButton: return "orange"; - case Qt.RightButton: return "magenta"; - default: return "green"; - } - })(handler.point.pressedButtons) + property color blinkColor: "red" + function tapFeedback(button) { + blinkColor = buttonToBlinkColor(button); + start(); + } loops: 3 ScriptAction { script: rect.border.color = borderBlink.blinkColor } PauseAnimation { duration: 100 } @@ -130,6 +130,14 @@ Item { } } + function buttonToBlinkColor(button) { + switch (button) { + case Qt.MiddleButton: return "orange"; + case Qt.RightButton: return "magenta"; + default: return "green"; + } + } + Row { spacing: 6 Text { text: "accepted mouse clicks:"; anchors.verticalCenter: leftAllowedCB.verticalCenter } |