Allow implicit mouse grab by accepting only on press

If we install a DragHandler on a Controls Button and try to drag it:
on press, the DragHandler takes a passive grab, and the Button accepts
the event, which gives it an implicit exclusive grab. Then when we drag
past the drag threshold, the DragHandler takes over the exclusive grab;
but we also deliver the mouse move to the Button, because it already had
the exclusive grab before. It doesn't ignore() the event, but we do not
want to interpret the accepted state as a reason for the Button to
re-grab the mouse, because it's just a move, not a press. This should
restore the behavior to what we had in Qt 5.

Pick-to: 6.4
Task-number: QTBUG-105610
Change-Id: I77e185b2737da19848e206cf08fc62cf62930d92
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Shawn Rutledge 2022-08-16 15:50:18 +02:00
parent fc088c4d5a
commit 68dc224920
1 changed files with 1 additions and 1 deletions

View File

@ -2079,7 +2079,7 @@ void QQuickDeliveryAgentPrivate::deliverMatchingPointsToItem(QQuickItem *item, b
item->mouseUngrabEvent();
lastUngrabbed = item;
}
} else if (item->isEnabled() && item->isVisible() && point.state() != QEventPoint::State::Released) {
} else if (item->isEnabled() && item->isVisible() && point.state() == QEventPoint::State::Pressed) {
pointerEvent->setExclusiveGrabber(point, item);
}
point.setAccepted(true);