diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-05-03 11:15:49 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-05-27 14:26:35 +0200 |
commit | 42ae5a32eb384cb7042eeace193aa42637970387 (patch) | |
tree | c4ce2e9bcfd0e8703828406a7d53069df328c828 /src | |
parent | 1b56c6ebb3fa66ebf0f7366bd9ba5a50089f4d95 (diff) |
Keep DragHandler active while dragging even if other event happens
QQuickPointerHandler::handlePointerEvent() calls setActive(false)
when wantsPointerEvent() returns false (except for a NativeGesture
event), for the sake of deactivating reliably when it receives an
event which it does not handle. Now we need one more exception, because
it's not what we want in DragHandler while dragging: If we get a
wheel event, that should not interrupt the current drag operation.
Thus, we change the logic in wantsPointerEvent to consider even events
we wouldn't normally handle while the DragHandler is active.
In handlePointerEventImpl, we then simply ignore them.
Fixes: QTBUG-91549
Change-Id: I24e8bd890a21b244c9964f4df76986688085fa87
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit 40bbf1e8fddebb0974426a03b0f48dfc08f942de)
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/handlers/qquickdraghandler.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/quick/handlers/qquickdraghandler.cpp b/src/quick/handlers/qquickdraghandler.cpp index 980481303f..9471ef7660 100644 --- a/src/quick/handlers/qquickdraghandler.cpp +++ b/src/quick/handlers/qquickdraghandler.cpp @@ -182,7 +182,13 @@ void QQuickDragHandler::onActiveChanged() bool QQuickDragHandler::wantsPointerEvent(QPointerEvent *event) { if (!QQuickMultiPointHandler::wantsPointerEvent(event)) - return false; + /* Do handle other events than we would normally care about + while we are still doing a drag; otherwise we would suddenly + become inactive when a wheel event arrives during dragging. + This extra condition needs to be kept in sync with + handlePointerEventImpl */ + if (!active()) + return false; #if QT_CONFIG(gestures) if (event->type() == QEvent::NativeGesture) @@ -194,6 +200,9 @@ bool QQuickDragHandler::wantsPointerEvent(QPointerEvent *event) void QQuickDragHandler::handlePointerEventImpl(QPointerEvent *event) { + if (active() && !QQuickMultiPointHandler::wantsPointerEvent(event)) + return; // see QQuickDragHandler::wantsPointerEvent; we don't want to handle those events + QQuickMultiPointHandler::handlePointerEventImpl(event); event->setAccepted(true); |