diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-12-14 22:08:47 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-12-15 14:03:55 +0100 |
commit | 83bf594fbd0e649f64a1daa601bd3fe716dac970 (patch) | |
tree | 9ddb6569ecb3a069e775ae9357c8979acad91a08 /src/quick/handlers | |
parent | 848f40f30e46322286d75923afd6a33f42dbfe46 (diff) |
Pointer handlers: don't emit canceled() when an extra button interrupts
If the intention is that a handler should react only to the left mouse
button (by default, acceptedButtons == Qt.LeftButton), and the user
presses the right button while the handler is already active, it
de-activates, because wantsPointerEvent() returns false. But now it will
no longer emit canceled() in that case. The docs for the canceled signal
say "If this handler has already grabbed the given point, this signal is
emitted when the grab is stolen by a different Pointer Handler or Item."
But in this case the handler gives up its grab voluntarily, it's not
being stolen by anything else.
Probably we were emitting canceled because it's intuitive that the
gesture is being canceled because something weird happened. But that's
not the documented reason for emitting this signal, and it's perhaps
inconsistent with the fact that dragging can be resumed.
The mechanism for emitting when another handler or item takes over the
grab begins in QPointingDevicePrivate::setExclusiveGrabber(), which
emits grabChanged(), which is connected to
QQuickDeliveryAgentPrivate::onGrabChanged(), which will call
onGrabChanged() on the handler, and the base class implementation
QQuickPointerHandler::onGrabChanged() will emit canceled(). At least in
this case a handler does not need to decide on its own to emit.
[ChangeLog][QtQuick][Event Handlers] A Pointer Handler no longer emits
the canceled() signal when it deactivates due to violating conditions
(such as pressing the right button when acceptedButtons == LeftButton).
Fixes: QTBUG-102201
Pick-to: 6.5
Change-Id: Ibe67c8f2a5e44d96df3a788ca1ee4e43f7de658d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/quick/handlers')
-rw-r--r-- | src/quick/handlers/qquickpointerhandler.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/quick/handlers/qquickpointerhandler.cpp b/src/quick/handlers/qquickpointerhandler.cpp index 80cf77c627..3a15eb4d41 100644 --- a/src/quick/handlers/qquickpointerhandler.cpp +++ b/src/quick/handlers/qquickpointerhandler.cpp @@ -660,10 +660,8 @@ void QQuickPointerHandler::handlePointerEvent(QPointerEvent *event) setActive(false); for (int i = 0; i < event->pointCount(); ++i) { auto &pt = event->point(i); - if (event->exclusiveGrabber(pt) == this && pt.state() != QEventPoint::Stationary) { + if (event->exclusiveGrabber(pt) == this && pt.state() != QEventPoint::Stationary) event->setExclusiveGrabber(pt, nullptr); - onGrabChanged(this, QPointingDevice::CancelGrabExclusive, event, pt); - } } } d->currentEvent = nullptr; |