Handle QEvent::TouchCancel in QML_TRANSLATE_TOUCH_TO_MOUSE mode
authorMartin Jones <martin.jones@nokia.com>
Thu, 8 Mar 2012 03:41:19 +0000 (13:41 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 9 Mar 2012 08:56:08 +0000 (09:56 +0100)
Just remove the mouse grab.  The elements will react to this and
correct their state.

Change-Id: I8b91295606eaface54aa95b1500e7b138d9bc82e
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
src/quick/items/qquickcanvas.cpp

index 461236d..d73701e 100644 (file)
@@ -374,6 +374,14 @@ static QQuickMouseEventEx touchToMouseEvent(QEvent::Type type, const QTouchEvent
 
 void QQuickCanvasPrivate::translateTouchToMouse(QTouchEvent *event)
 {
+    if (event->type() == QEvent::TouchCancel) {
+        touchMouseId = -1;
+        if (!mouseGrabberItem)
+            return;
+        mouseGrabberItem->ungrabMouse();
+        mouseGrabberItem = 0;
+        return;
+    }
     for (int i = 0; i < event->touchPoints().count(); ++i) {
         QTouchEvent::TouchPoint p = event->touchPoints().at(i);
         if (touchMouseId == -1 && p.state() & Qt::TouchPointPressed) {