aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-11-27 08:59:20 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2020-11-30 18:16:26 +0100
commit1e1674849a89db54cdbcc4e995300e3ec1624c3a (patch)
tree535cf0bf75be5a75d40c3db518991e5fc38887b2 /src/quick/items
parente2a74579850d89d229dad918404a8d8ecebb80b3 (diff)
Allow parent to filter out-of-bounds synth-mouse for grabbing handler
Consider Flickable { Text { TapHandler { gesturePolicy: TapHandler.ReleaseWithinBounds } } } On press, TapHandler gets the exclusive grab. Now drag vertically. The Text is short in stature, so your finger soon strays out of bounds of the Text, likely before you have dragged past the drag threshold. In this case, we want Flickable to continue to filter the move events because of the fact that TapHandler is the grabber. If it was a MouseArea instead of a TapHandler, it already worked that way; so this makes behavior of handlers more consistent with that. More specifically: QQuickPointerTouchEvent::touchEventForItem() now generates a touch event even if the touchpoint is not within the bounds of the given item, but is grabbed by one of that item's handlers. Until now, we had that exception only if it was grabbed by the item itself. tst_FlickableInterop::touchAndDragHandlerOnFlickable now always drags the delegate at index 2 (the third one) from its upper-right corner, upwards and to the left. The first drag goes outside the delegate's bounds, but the Flickable/ListView/TableView filters and takes over anyway (on the next drag), to prove that it is correctly depending on the grab that the TapHandler (or DragHandler) took on press. Pick-to: 5.15 Pick-to: 6.0 Fixes: QTBUG-75223 Change-Id: Ie4e22c87be0af9aa3ff0146067b7705949b15c40 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/qquickitem.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index a8cb45a891..ccd1168278 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -8377,9 +8377,9 @@ QQuickItemLayer *QQuickItemPrivate::layer() const
coordinate system.
Returns an invalid event with type \l QEvent::None if all points are
- stationary, or there are no points inside the item, or none of the points
- were pressed inside and the item was not grabbing any of them and
- \a isFiltering is false.
+ stationary; or there are no points inside the item; or none of the points
+ were pressed inside, neither the item nor any of its handlers is grabbing
+ any of them, and \a isFiltering is false.
When \a isFiltering is true, it is assumed that the item cares about all
points which are inside its bounds, because most filtering items need to
@@ -8397,11 +8397,18 @@ void QQuickItemPrivate::localizedTouchEvent(const QTouchEvent *event, bool isFil
for (auto &p : event->points()) {
if (p.isAccepted())
continue;
- // include points where item is the grabber
+
+ // include points where item is the grabber, or if any of its handlers is the grabber while some parent is filtering
auto pointGrabber = event->exclusiveGrabber(p);
bool isGrabber = (pointGrabber == q);
+ if (!isGrabber && pointGrabber && isFiltering) {
+ auto handlerGrabber = qmlobject_cast<QQuickPointerHandler *>(pointGrabber);
+ if (handlerGrabber && handlerGrabber->parentItem() == q)
+ isGrabber = true;
+ }
if (isGrabber)
anyGrabber = true;
+
// include points inside the bounds if no other item is the grabber or if the item is filtering
const auto localPos = q->mapFromScene(p.scenePosition());
bool isInside = q->contains(localPos);