Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
6.0, 6.3.0 Beta2
-
None
Description
In Qt 5 we had this code:
void QQuickEventPoint::setGrabberItem(QQuickItem *grabber) { if (grabber != m_exclusiveGrabber.data()) { QQuickPointerHandler *oldGrabberHandler = grabberPointerHandler(); if (oldGrabberHandler && !oldGrabberHandler->approveGrabTransition(this, grabber)) return; if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) { qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << Qt::hex << m_pointId << pointStateString(this) << "@" << m_scenePos << ": grab" << m_exclusiveGrabber << "->" << grabber; }
In Qt 6, we have QPointerEvent::setExclusiveGrabber() and we're using it directly. It's in QtGui, and knows nothing about how to get approval for a grab transition. So it seems we will need to write a wrapper function in Qt Quick to restore this feature, or else come up with some sort of callback mechanism so that Qt Quick can provide an approver function that QtGui can call. And the nice thing about an approver function would be that even if e.g. a QWidget or something in Qt Quick 3D tries to take the grab from a handler, it would have a chance to say no (in case of hybrid applications); whereas with a wrapper function just for Qt Quick, we'd have to remember to use it everywhere (add a note to QPointerEvent::setExclusiveGrabber() that it should never be called directly from Qt Quick).
It comes up when trying to use a TapHandler to open a context menu on a TextArea, for example:
import QtQuick import QtQuick.Controls TextArea { id: textArea focus: true text: "test message" TapHandler { acceptedButtons: Qt.RightButton gesturePolicy: TapHandler.ReleaseWithinBounds grabPermissions: PointerHandler.CanTakeOverFromAnything onTapped: contextMenu.popup(point.position) } Menu { id: contextMenu MenuItem { text: "Cut" } MenuItem { text: "Copy" } MenuItem { text: "Paste" } } }
When pressing the right mouse button, TapHandler gets a grab first (gesturePolicy makes it an exclusive grab), and TextArea gets to take over the grab without even asking, merely by accepting the event. That is because QQuickDeliveryAgentPrivate::deliverMatchingPointsToItem() calls pointerEvent->setExclusiveGrabber() directly. But we have many such places in Qt Quick.
Attachments
Issue Links
- is required for
-
QTBUG-105610 should be able to add a DragHandler to a Button or other control
- Closed
-
QTBUG-101400 Get rid of QQuickMouseEvent signals in Controls; make sure pointer handlers are a good substitute
- Reported
- relates to
-
QTBUG-95279 PinchHandler can cause MouseArea to go unresponsive
- Closed
-
QTBUG-100104 Using TapHandler in a QML Dialog incorrectly propagates mouse events to DragHandler
- Open
- replaces
-
QTBUG-54303 Decide what to do about grabs
- Closed
Gerrit Reviews
For Gerrit Dashboard: QTBUG-101398 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
398772,7 | Add QPtDevPriv::setGrabTransitionApprover; setExclGrabber: return bool | dev | qt/qtbase | Status: NEW | -1 | 0 |
398773,3 | setGrabTransitionApprover when handling each "begin" event | dev | qt/qtdeclarative | Status: NEW | 0 | 0 |