diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2024-02-16 21:49:42 -0700 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-02-22 21:13:18 +0000 |
commit | 8473329c20c00863e759f22b7326ab8220163dbc (patch) | |
tree | 51c9e877ac609d941376258737666387662fb1c4 | |
parent | 56c0a6f66e92a07e6427fd3b9ba0b6eed1934674 (diff) |
Accept mouse or touchpad in snippets with acceptedDevices
This is a workaround for platforms (such as Wayland and macOS) that are
sometimes failing to distinguish mouse and touchpad. It's better for
illustrative purposes anyway, since a laptop user may really be using a
touchpad rather than a mouse, and we hope to eventually distinguish
them on as many platforms as possible.
Task-number: QTBUG-63363
Task-number: QTBUG-112432
Pick-to: 6.5
Change-Id: Ic7a374f1257d4aa57f29385b44da85ccaf4f5ec6
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
(cherry picked from commit 32a56ba8f08ddefa3d20c3003ed8599553b6d960)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit e801fced57c4844311587a397521cedd15ab77aa)
-rw-r--r-- | src/quick/doc/snippets/pointerHandlers/hoverMouseOrStylus.qml | 2 | ||||
-rw-r--r-- | src/quick/handlers/qquickhoverhandler.cpp | 3 | ||||
-rw-r--r-- | src/quick/handlers/qquickpointerdevicehandler.cpp | 5 |
3 files changed, 8 insertions, 2 deletions
diff --git a/src/quick/doc/snippets/pointerHandlers/hoverMouseOrStylus.qml b/src/quick/doc/snippets/pointerHandlers/hoverMouseOrStylus.qml index f79133df8d..40c9367f6a 100644 --- a/src/quick/doc/snippets/pointerHandlers/hoverMouseOrStylus.qml +++ b/src/quick/doc/snippets/pointerHandlers/hoverMouseOrStylus.qml @@ -15,7 +15,7 @@ Rectangle { HoverHandler { id: mouse - acceptedDevices: PointerDevice.Mouse + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad cursorShape: Qt.PointingHandCursor } } diff --git a/src/quick/handlers/qquickhoverhandler.cpp b/src/quick/handlers/qquickhoverhandler.cpp index c6dbd46e0b..5bf53235c5 100644 --- a/src/quick/handlers/qquickhoverhandler.cpp +++ b/src/quick/handlers/qquickhoverhandler.cpp @@ -231,6 +231,9 @@ void QQuickHoverHandler::setHovered(bool hovered) \value PointerDevice.Puck A digitizer with crosshairs, on a graphics tablet. \value PointerDevice.AllDevices Any type of pointing device. + \note Not all platforms are yet able to distinguish mouse and touchpad; and + on those that do, you often want to make mouse and touchpad behavior the same. + \sa QInputDevice::DeviceType */ diff --git a/src/quick/handlers/qquickpointerdevicehandler.cpp b/src/quick/handlers/qquickpointerdevicehandler.cpp index 4c871d93f5..a6b98ec2b5 100644 --- a/src/quick/handlers/qquickpointerdevicehandler.cpp +++ b/src/quick/handlers/qquickpointerdevicehandler.cpp @@ -110,7 +110,7 @@ Qt::KeyboardModifiers QQuickPointerDeviceHandler::acceptedModifiers() const \qml Item { TapHandler { - acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad | PointerDevice.Stylus onTapped: console.log("clicked") } TapHandler { @@ -119,6 +119,9 @@ Qt::KeyboardModifiers QQuickPointerDeviceHandler::acceptedModifiers() const } } \endqml + + \note Not all platforms are yet able to distinguish mouse and touchpad; and + on those that do, you often want to make mouse and touchpad behavior the same. */ void QQuickPointerDeviceHandler::setAcceptedDevices(QPointingDevice::DeviceTypes acceptedDevices) { |