diff options
| author | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-09-07 16:54:44 +0200 |
|---|---|---|
| committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-09-08 15:26:03 +0200 |
| commit | 5864644ac8bc3c561696ffef5d033b1cab7d950f (patch) | |
| tree | 7321b90368a93bde1921550b54166bed8f3374ec /src/quick/doc/snippets/pointerHandlers | |
| parent | deccfa4636400cee32efb1ba89eda1c88921ee3a (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
Pick-to: 6.2 6.2.0
Change-Id: I6d25300cbfceb56f27452eac4b29b66bd1b2a41a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/quick/doc/snippets/pointerHandlers')
| -rw-r--r-- | src/quick/doc/snippets/pointerHandlers/tapHandlerOnTapped.qml | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/quick/doc/snippets/pointerHandlers/tapHandlerOnTapped.qml b/src/quick/doc/snippets/pointerHandlers/tapHandlerOnTapped.qml index deff59d034..2c682df584 100644 --- a/src/quick/doc/snippets/pointerHandlers/tapHandlerOnTapped.qml +++ b/src/quick/doc/snippets/pointerHandlers/tapHandlerOnTapped.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -48,7 +48,7 @@ ** ****************************************************************************/ //![0] -import QtQuick 2.12 +import QtQuick Rectangle { width: 100 @@ -56,8 +56,8 @@ Rectangle { TapHandler { acceptedButtons: Qt.LeftButton | Qt.RightButton - onTapped: (eventPoint)=> console.log("tapped", eventPoint.event.device.name, - "button", eventPoint.event.button, + onTapped: (eventPoint, button)=> console.log("tapped", eventPoint.device.name, + "button", button, "@", eventPoint.scenePosition) } } |
