Correct double, triple click handling in canvas when in touch mode
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Sat, 24 Mar 2012 08:03:58 +0000 (10:03 +0200)
committerQt by Nokia <qt-info@nokia.com>
Sun, 25 Mar 2012 23:42:01 +0000 (01:42 +0200)
The correct MouseArea signal sequence for a triple click is press,
release, click, press, doubleclick, release, press, release, click.
However QQuickCanvas sent the doubleclick before the press and did not
reset the timestamp of the last press, resulting in a sequence with
multiple doubleclicks and missing press signals.

Change-Id: Ied5f3ea93d3ad28128ce7db5c8190ab48961da6d
Reviewed-by: Martin Jones <martin.jones@nokia.com>
src/quick/items/qquickcanvas.cpp

index 6c96482..3a9820d 100644 (file)
@@ -389,7 +389,17 @@ void QQuickCanvasPrivate::translateTouchToMouse(QTouchEvent *event)
             bool doubleClick = event->timestamp() - touchMousePressTimestamp
                             < static_cast<ulong>(qApp->styleHints()->mouseDoubleClickInterval());
             touchMousePressTimestamp = event->timestamp();
+            QQuickMouseEventEx me = touchToMouseEvent(QEvent::MouseButtonPress, p);
+            me.setTimestamp(event->timestamp());
+            me.setAccepted(false);
+            me.setCapabilities(event->device()->capabilities());
+            deliverMouseEvent(&me);
+            if (me.isAccepted()) {
+                touchMouseId = p.id();
+                event->setAccepted(true);
+            }
             if (doubleClick) {
+                touchMousePressTimestamp = 0;
                 QQuickMouseEventEx me = touchToMouseEvent(QEvent::MouseButtonDblClick, p);
                 me.setTimestamp(event->timestamp());
                 me.setAccepted(false);
@@ -407,15 +417,6 @@ void QQuickCanvasPrivate::translateTouchToMouse(QTouchEvent *event)
                     }
                 }
             }
-            QQuickMouseEventEx me = touchToMouseEvent(QEvent::MouseButtonPress, p);
-            me.setTimestamp(event->timestamp());
-            me.setAccepted(false);
-            me.setCapabilities(event->device()->capabilities());
-            deliverMouseEvent(&me);
-            if (me.isAccepted()) {
-                touchMouseId = p.id();
-                event->setAccepted(true);
-            }
             if (touchMouseId != -1)
                 break;
         } else if (p.id() == touchMouseId) {