From 406d6d33a6c0c5f99dfa31e2eb681b1fefcd5fe0 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 22 Aug 2013 17:20:52 +0200 Subject: Expose drag threshold in MouseArea In several cases such as for creating a Slider, it is useful to have a 0 pixel threshold in order to initiate a drag operation. We have previously hardcoded this to a platform dependent (usually 10 pixel) value for MouseArea. Note that we have no way of indicating the version/revision number in a grouped property for documentation at the moment. In addition we deliberately had to remove the REVISION from the property because it is blocked by QTBUG-33179. However, since this is not a user-creatable type it should not cause any issues in practice. This patch adds MouseArea.drag.threshold in order to improve on this. Change-Id: Ia4871e64fab39e30c4494f00be99ad38cdd630df Reviewed-by: J-P Nurmi --- src/quick/items/qquickmousearea.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/quick/items/qquickmousearea.cpp') diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp index 8a73a5d73d..39f07f2afd 100644 --- a/src/quick/items/qquickmousearea.cpp +++ b/src/quick/items/qquickmousearea.cpp @@ -48,10 +48,7 @@ #include #include - #include -#include -#include #include @@ -695,8 +692,8 @@ void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event) 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))) { + && (QQuickWindowPrivate::dragOverThreshold(dragPos.x() - startPos.x(), Qt::XAxis, event, d->drag->threshold()) + || QQuickWindowPrivate::dragOverThreshold(dragPos.y() - startPos.y(), Qt::YAxis, event, d->drag->threshold()))) { setKeepMouseGrab(true); d->stealMouse = true; d->startScene = event->windowPos(); @@ -1189,6 +1186,7 @@ void QQuickMouseArea::setCursorShape(Qt::CursorShape shape) \qmlproperty real QtQuick2::MouseArea::drag.minimumY \qmlproperty real QtQuick2::MouseArea::drag.maximumY \qmlproperty bool QtQuick2::MouseArea::drag.filterChildren + \qmlproperty real QtQuick2::MouseArea::drag.threshold \c drag provides a convenient way to make an item draggable. @@ -1213,6 +1211,10 @@ void QQuickMouseArea::setCursorShape(Qt::CursorShape shape) If \c drag.filterChildren is set to true, a drag can override descendant MouseAreas. This enables a parent MouseArea to handle drags, for example, while descendants handle clicks: + \c drag.threshold determines the threshold in pixels of when the drag operation should + start. By default this is bound to a platform dependent value. This property was added in + Qt Quick 2.2. + \snippet qml/mousearea/mouseareadragfilter.qml dragfilter */ -- cgit v1.2.3