diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-03-03 02:56:07 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-03-03 02:56:07 (GMT) |
commit | fa23a63af230f0c917cc56e6c652c01e6695ef63 (patch) | |
tree | 1137b732d062e541fca3e63a40e67a07f2eb2511 | |
parent | b0b19d286e10d307db4b9e477d4463eabc2b319d (diff) | |
download | Qt-fa23a63af230f0c917cc56e6c652c01e6695ef63.zip Qt-fa23a63af230f0c917cc56e6c652c01e6695ef63.tar.gz Qt-fa23a63af230f0c917cc56e6c652c01e6695ef63.tar.bz2 |
Fix mouse stealing in nested flickables.
Set intent to steal mouse, but don't steal the initiating event. This
allows other, higher Flickables to override lower.
Task-number: QTBUG-5292
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeflickable.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index c54ddd0..2fdd720 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -682,7 +682,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent else rejectY = true; } - if (!rejectY) { + if (!rejectY && stealMouse) { _moveY.setValue(newY); moved = true; } @@ -709,7 +709,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent else rejectX = true; } - if (!rejectX) { + if (!rejectX && stealMouse) { _moveX.setValue(newX); moved = true; } @@ -752,6 +752,8 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event) { Q_Q(QDeclarativeFlickable); + stealMouse = false; + q->setKeepMouseGrab(false); pressed = false; if (lastPosTime.isNull()) return; @@ -781,7 +783,6 @@ void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEv fixupX(); } - stealMouse = false; lastPosTime = QTime(); if (!timeline.isActive()) @@ -804,6 +805,8 @@ void QDeclarativeFlickable::mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_D(QDeclarativeFlickable); if (d->interactive) { d->handleMouseMoveEvent(event); + if (d->stealMouse) + setKeepMouseGrab(true); event->accept(); } else { QDeclarativeItem::mouseMoveEvent(event); @@ -1141,7 +1144,8 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) QGraphicsScene *s = scene(); QDeclarativeItem *grabber = s ? qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()) : 0; - if ((d->stealMouse || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) { + bool stealThisEvent = d->stealMouse; + if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) { mouseEvent.setAccepted(false); for (int i = 0x1; i <= 0x10; i <<= 1) { if (event->buttons() & i) { @@ -1176,17 +1180,19 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) break; } grabber = qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()); - if (grabber && d->stealMouse && !grabber->keepMouseGrab() && grabber != this) { + if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) { d->clearDelayedPress(); grabMouse(); } - return d->stealMouse || d->delayedPressEvent; + return stealThisEvent || d->delayedPressEvent; } else if (!d->lastPosTime.isNull()) { d->lastPosTime = QTime(); } - if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) + if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) { d->clearDelayedPress(); + d->stealMouse = false; + } return false; } |