Make PieMenu in pointer handlers example work with mouse right-click

It opens instantly with right-click; whereas it animates open with
a finger or stylus, to avoid accidental activation, as before.

Pick-to: 6.5
Change-Id: I6f530fb6da67c735fe3aae4545c8040f49e8dc05
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
(cherry picked from commit 86081091f9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 08b00cf7e3)
This commit is contained in:
Shawn Rutledge 2024-01-12 16:07:31 -07:00 committed by Qt Cherry-pick Bot
parent 22b81f1bb8
commit 4465415de1
1 changed files with 5 additions and 1 deletions

View File

@ -9,6 +9,7 @@ TapHandler {
signal triggered(string text)
id: menuTap
acceptedButtons: Qt.RightButton
gesturePolicy: TapHandler.DragWithinBounds
onPressedChanged: if (pressed) {
impl.x = point.position.x - impl.width / 2
@ -22,7 +23,10 @@ TapHandler {
parent: menuTap.parent
width: 100
height: 100
scale: Math.min(1, Math.max(0, menuTap.timeHeld * 4))
// with touchscreen or stylus, long-press slowly expands the menu to size
// with mouse or touchpad right-click, it opens instantly
scale: menuTap.point.device.pointerType === PointerDevice.Generic ?
1 : Math.min(1, Math.max(0, menuTap.timeHeld * 4))
opacity: scale * 2
visible: menuTap.pressed
property Shape highlightedShape: null