diff options
author | Andrew den Exter <andrew.den.exter@jollamobile.com> | 2013-02-15 21:29:32 +1000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-22 02:10:21 +0100 |
commit | 7a1282a9edd8afa4645d7d449ca2ed3746fb8d71 (patch) | |
tree | 5c6c9f1dd46bfbd55ad8c508581ae631e3ecce22 /src/quick/items | |
parent | b939bc6300d79862340ff35dc8910663bda5744f (diff) |
MouseArea shouldn't grab the mouse until there is an effective drag.
A MouseArea shouldn't prevent a parent MouseArea or Flickable from
handling a drag event unless it is going to do something useful with
it.
Task-number: 29717
Change-Id: I24016994f6cf9116382ef7faeb50b10e5716e10e
Reviewed-by: Alan Alpert <aalpert@rim.com>
Diffstat (limited to 'src/quick/items')
-rw-r--r-- | src/quick/items/qquickmousearea.cpp | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp index e75a60181f..2fa52d9ed2 100644 --- a/src/quick/items/qquickmousearea.cpp +++ b/src/quick/items/qquickmousearea.cpp @@ -797,9 +797,6 @@ void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event) curLocalPos = event->windowPos(); } - qreal dx = qAbs(curLocalPos.x() - startLocalPos.x()); - qreal dy = qAbs(curLocalPos.y() - startLocalPos.y()); - if (keepMouseGrab() && d->stealMouse && !d->drag->active()) d->drag->setActive(true); @@ -807,38 +804,30 @@ void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event) ? d->drag->target()->parentItem()->mapFromScene(d->targetStartPos) : d->targetStartPos; - QPointF dragPos = d->drag->target()->position(); - bool dragX = drag()->axis() & QQuickDrag::XAxis; bool dragY = drag()->axis() & QQuickDrag::YAxis; - if (dragX && d->drag->active()) { - qreal x = (curLocalPos.x() - startLocalPos.x()) + startPos.x(); - if (x < drag()->xmin()) - x = drag()->xmin(); - else if (x > drag()->xmax()) - x = drag()->xmax(); - dragPos.setX(x); + QPointF dragPos = d->drag->target()->position(); + if (dragX) { + dragPos.setX(qBound( + d->drag->xmin(), + startPos.x() + curLocalPos.x() - startLocalPos.x(), + d->drag->xmax())); } - if (dragY && d->drag->active()) { - qreal y = (curLocalPos.y() - startLocalPos.y()) + startPos.y(); - if (y < drag()->ymin()) - y = drag()->ymin(); - else if (y > drag()->ymax()) - y = drag()->ymax(); - dragPos.setY(y); + if (dragY) { + dragPos.setY(qBound( + d->drag->ymin(), + startPos.y() + curLocalPos.y() - startLocalPos.y(), + d->drag->ymax())); } - d->drag->target()->setPosition(dragPos); - - if (!keepMouseGrab()) { - bool xDragged = QQuickWindowPrivate::dragOverThreshold(dx, Qt::XAxis, event); - bool yDragged = QQuickWindowPrivate::dragOverThreshold(dy, Qt::YAxis, event); - if ((!dragY && !yDragged && dragX && xDragged) - || (!dragX && !xDragged && dragY && yDragged) - || (dragX && dragY && (xDragged || yDragged))) { - setKeepMouseGrab(true); - d->stealMouse = true; - } + if (d->drag->active()) + d->drag->target()->setPosition(dragPos); + + if (!keepMouseGrab() + && (QQuickWindowPrivate::dragOverThreshold(dragPos.x() - startPos.x(), Qt::XAxis, event) + || QQuickWindowPrivate::dragOverThreshold(dragPos.y() - startPos.y(), Qt::YAxis, event))) { + setKeepMouseGrab(true); + d->stealMouse = true; } d->moved = true; |