From 2ecf1f5d8ae37bdb4624bd1e3888a65ec357f7b3 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 8 Mar 2012 13:41:19 +1000 Subject: [PATCH] Handle QEvent::TouchCancel in QML_TRANSLATE_TOUCH_TO_MOUSE mode Just remove the mouse grab. The elements will react to this and correct their state. Change-Id: I8b91295606eaface54aa95b1500e7b138d9bc82e Reviewed-by: Michael Brasser --- src/quick/items/qquickcanvas.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/quick/items/qquickcanvas.cpp b/src/quick/items/qquickcanvas.cpp index 461236d..d73701e 100644 --- a/src/quick/items/qquickcanvas.cpp +++ b/src/quick/items/qquickcanvas.cpp @@ -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) { -- 2.7.4