diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2013-05-08 15:21:59 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-10 15:01:14 +0100 |
commit | fe2de633f9b9454ec8a9c2a5874ad85f49d8d54d (patch) | |
tree | d15cc7bb53673f8b9b6af8a0c4648f8b29bb80b4 /src/quick/items/qquickmultipointtoucharea_p.h | |
parent | 2df6031b5935fafcada04bc15b281c63bdbfabf9 (diff) |
MultiPointTouchArea: handles mouse too, unless mouseEnabled is false
A new boolean property mouseEnabled is introduced (true by default).
If set to true, then it will handle any non-synthetic mouse event
as if it were a touch point.
If set to false, the area becomes transparent for real mouse events
so that a MultiPointTouchArea can be stacked on top of a MouseArea
in order to separate handling of touch and mouse.
In either case it continues to absorb and ignore synthesized mouse
events (including touch-to-mouse synthesis in QQuickWindow).
[ChangeLog][QtQuick][MultiPointTouchArea]handles mouse as a touchpoint;
added mouseEnabled property to permit transparent pass-through to
mouse-sensitive items
Change-Id: I4af94d838f0060154494589c0f15c6858ee89ddb
Task-number: QTBUG-31047
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Diffstat (limited to 'src/quick/items/qquickmultipointtoucharea_p.h')
-rw-r--r-- | src/quick/items/qquickmultipointtoucharea_p.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/quick/items/qquickmultipointtoucharea_p.h b/src/quick/items/qquickmultipointtoucharea_p.h index 83cc407401..9dbca2be54 100644 --- a/src/quick/items/qquickmultipointtoucharea_p.h +++ b/src/quick/items/qquickmultipointtoucharea_p.h @@ -191,6 +191,7 @@ class Q_AUTOTEST_EXPORT QQuickMultiPointTouchArea : public QQuickItem Q_PROPERTY(QQmlListProperty<QQuickTouchPoint> touchPoints READ touchPoints) Q_PROPERTY(int minimumTouchPoints READ minimumTouchPoints WRITE setMinimumTouchPoints NOTIFY minimumTouchPointsChanged) Q_PROPERTY(int maximumTouchPoints READ maximumTouchPoints WRITE setMaximumTouchPoints NOTIFY maximumTouchPointsChanged) + Q_PROPERTY(bool mouseEnabled READ mouseEnabled WRITE setMouseEnabled NOTIFY mouseEnabledChanged) public: QQuickMultiPointTouchArea(QQuickItem *parent=0); @@ -200,6 +201,8 @@ public: void setMinimumTouchPoints(int num); int maximumTouchPoints() const; void setMaximumTouchPoints(int num); + bool mouseEnabled() const { return _mouseEnabled; } + void setMouseEnabled(bool arg); QQmlListProperty<QQuickTouchPoint> touchPoints() { return QQmlListProperty<QQuickTouchPoint>(this, 0, QQuickMultiPointTouchArea::touchPoint_append, QQuickMultiPointTouchArea::touchPoint_count, QQuickMultiPointTouchArea::touchPoint_at, 0); @@ -229,6 +232,7 @@ Q_SIGNALS: void touchUpdated(const QList<QObject*> &touchPoints); void minimumTouchPointsChanged(); void maximumTouchPointsChanged(); + void mouseEnabledChanged(); protected: void touchEvent(QTouchEvent *); @@ -241,9 +245,11 @@ protected: void addTouchPrototype(QQuickTouchPoint* prototype); void addTouchPoint(const QTouchEvent::TouchPoint *p); + void addTouchPoint(const QMouseEvent *e); void clearTouchLists(); void updateTouchPoint(QQuickTouchPoint*, const QTouchEvent::TouchPoint*); + void updateTouchPoint(QQuickTouchPoint *dtp, const QMouseEvent *e); void updateTouchData(QEvent*); bool sendMouseEvent(QMouseEvent *event); @@ -265,7 +271,11 @@ private: QList<QObject*> _movedTouchPoints; int _minimumTouchPoints; int _maximumTouchPoints; + QQuickTouchPoint *_mouseTouchPoint; // exists when mouse button is down and _mouseEnabled is true; null otherwise + QTouchEvent::TouchPoint _mouseQpaTouchPoint; // synthetic QPA touch point to hold state and position of the mouse + QPointF _mousePos; bool _stealMouse; + bool _mouseEnabled; }; QT_END_NAMESPACE |