From fe2de633f9b9454ec8a9c2a5874ad85f49d8d54d Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 8 May 2013 15:21:59 +0200 Subject: 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 --- src/quick/items/qquickmultipointtoucharea_p.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/quick/items/qquickmultipointtoucharea_p.h') 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 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 touchPoints() { return QQmlListProperty(this, 0, QQuickMultiPointTouchArea::touchPoint_append, QQuickMultiPointTouchArea::touchPoint_count, QQuickMultiPointTouchArea::touchPoint_at, 0); @@ -229,6 +232,7 @@ Q_SIGNALS: void touchUpdated(const QList &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 _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 -- cgit v1.2.3