Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.5.0 Beta2, 6.6.0 FF
-
None
-
a6e196ce9 (dev), ae7069bfa (6.5), dd3484343 (6.5.0), b0bb5823e (6.4), a8fb5c36c (tqtc/lts-6.2), 18fe43ba3 (dev), 9ab50965d (6.5)
Description
I tried to do this:
/*! \qmlproperty enumeration QtQuick::TapHandler::gesturePolicy The spatial constraint for a tap or long press gesture to be recognized, in addition to the constraint that the release must occur before \l longPressThreshold has elapsed. If these constraints are not satisfied, the \l tapped signal is not emitted, and \l tapCount is not incremented. If the spatial constraint is violated, \l pressed transitions immediately from true to false, regardless of the time held. The \c gesturePolicy also affects grab behavior as described below. \value TapHandler.DragThreshold (the default value) The event point must not move significantly. If the mouse, finger or stylus moves past the system-wide drag threshold (QStyleHints::startDragDistance), the tap gesture is canceled, even if the button or finger is still pressed. This policy can be useful whenever TapHandler needs to cooperate with other input handlers (for example \l DragHandler) or event-handling Items (for example QtQuick Controls), because in this case TapHandler will not take the exclusive grab, but merely a \l {QPointerEvent::addPassiveGrabber()}{passive grab}. \snippet pointerHandlers/tapHanderOverlappingButtons.qml 1 \image pointerHandlers/tapHanderOverlappingButtons.gif \value TapHandler.WithinBounds If the event point leaves the bounds of the \c parent Item, the tap gesture is canceled. The TapHandler will take the \l {QPointerEvent::setExclusiveGrabber}{exclusive grab} on press, but will release the grab as soon as the boundary constraint is no longer satisfied. \snippet pointerHandlers/tapHanderButtonWithinBounds.qml 1 \image pointerHandlers/tapHanderButtonWithinBounds.gif \value TapHandler.ReleaseWithinBounds At the time of release (the mouse button is released or the finger is lifted), if the event point is outside the bounds of the \c parent Item, a tap gesture is not recognized. This corresponds to typical behavior for button widgets: you can cancel a click by dragging outside the button, and you can also change your mind by dragging back inside the button before release. Note that it's necessary for TapHandler to take the \l {QPointerEvent::setExclusiveGrabber}{exclusive grab} on press and retain it until release in order to detect this gesture. \snippet pointerHandlers/tapHanderButtonReleaseWithinBounds.qml 1 \image pointerHandlers/tapHanderButtonReleaseWithinBounds.gif \value TapHandler.DragWithinBounds On press, TapHandler takes the \l {QPointerEvent::setExclusiveGrabber}{exclusive grab}; after that, the event point can be dragged within the bounds of the \c parent item, while the \l timeHeld property keeps counting, and the \l longPressed() signal will be emitted regardless of drag distance. However, like \c WithinBounds, if the point leaves the bounds, the tap gesture is \l {PointerHandler::}{canceled()}, \l active() becomes \c false, and \l timeHeld stops counting. This is suitable for implementing press-drag-release components, such as menus, in which a single TapHandler detects press, \c timeHeld drives an "opening" animation, and then the user can drag to a menu item and release, while never leaving the bounds of the parent scene containing the menu. This value was added in Qt 6.3. \snippet pointerHandlers/dragReleaseMenu.qml 1 \image pointerHandlers/dragReleaseMenu.gif */
The result looks like this:
But I guess I will try using a table, because these \value sections would waste a lot of vertical space even if this actually worked. (That's the trouble with the push to have copious snippets in docs: they take a lot of space.)