aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickmousearea.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-12-05 10:28:20 +0100
committerShawn Rutledge <shawn.rutledge@digia.com>2015-01-28 17:14:37 +0000
commit44ab79012f1662a4efa7c506b6ebc4466c50b3e9 (patch)
tree856c2bb40a42da5fb905bc858af87505fa2a75e8 /src/quick/items/qquickmousearea.cpp
parent9a23ecfb58c4795a7d3e722088c81a823cfb8c8d (diff)
MouseArea: add scrollGestureEnabled property
If true, scroll gestures coming from the operating system can cause wheel to be emitted; if false, only an actual mouse wheel will do that. The photosurface example demostrates the use case. 1) the flick gesture on a trackpad should flick the underlying Flickable, not zoom an individual image 2) mouse wheel should zoom an individual image if the cursor is pointing to it 3) dragging an image on a touchscreen should be possible, independently of flicking the Flickable. This means multiPointTouchEnabled should be true, so we cannot interpret multiPointTouchEnabled to mean that multipoint touch scroll gestures should be disabled. Change-Id: Ie063556866f07b3fbadc53990b110edeed532710 Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Diffstat (limited to 'src/quick/items/qquickmousearea.cpp')
-rw-r--r--src/quick/items/qquickmousearea.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp
index dc7ba96c35..d6aa30835c 100644
--- a/src/quick/items/qquickmousearea.cpp
+++ b/src/quick/items/qquickmousearea.cpp
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(qmlVisualTouchDebugging, QML_VISUAL_TOUCH_DEBUGGING)
QQuickMouseAreaPrivate::QQuickMouseAreaPrivate()
-: enabled(true), hovered(false), longPress(false),
+: enabled(true), scrollGestureEnabled(true), hovered(false), longPress(false),
moved(false), stealMouse(false), doubleClick(false), preventStealing(false),
propagateComposedEvents(false), pressed(0)
#ifndef QT_NO_DRAGANDDROP
@@ -497,6 +497,36 @@ void QQuickMouseArea::setEnabled(bool a)
}
/*!
+ \qmlproperty bool QtQuick::MouseArea::scrollGestureEnabled
+
+ This property controls whether this MouseArea responds to scroll gestures
+ from non-mouse devices, such as the 2-finger flick gesture on a trackpad.
+ If set to false, the \l wheel signal be emitted only when the wheel event
+ comes from an actual mouse with a wheel, while scroll gesture events will
+ pass through to any other Item that will handle them. For example, the user
+ might perform a flick gesture while the cursor is over an item containing a
+ MouseArea, intending to interact with a Flickable which is underneath.
+ Setting this property to false will allow the PinchArea to handle the mouse
+ wheel or the pinch gesture, while the Flickable handles the flick gesture.
+
+ By default, this property is true.
+*/
+bool QQuickMouseArea::isScrollGestureEnabled() const
+{
+ Q_D(const QQuickMouseArea);
+ return d->scrollGestureEnabled;
+}
+
+void QQuickMouseArea::setScrollGestureEnabled(bool e)
+{
+ Q_D(QQuickMouseArea);
+ if (e != d->scrollGestureEnabled) {
+ d->scrollGestureEnabled = e;
+ emit scrollGestureEnabledChanged();
+ }
+}
+
+/*!
\qmlproperty bool QtQuick::MouseArea::preventStealing
This property holds whether the mouse events may be stolen from this
MouseArea.
@@ -821,7 +851,7 @@ void QQuickMouseArea::hoverLeaveEvent(QHoverEvent *event)
void QQuickMouseArea::wheelEvent(QWheelEvent *event)
{
Q_D(QQuickMouseArea);
- if (!d->enabled) {
+ if (!d->enabled || (!isScrollGestureEnabled() && event->source() != Qt::MouseEventNotSynthesized)) {
QQuickItem::wheelEvent(event);
return;
}