From ef0f5f5ed8cdb6dd70f728fd1873158785f43d27 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 21 Nov 2019 12:18:28 +0100 Subject: Don't send mouse events if we have touch support Unfortunately, using stopPropagation() and preventDefault() does not stop the mouse events from being sent for a touch. So we have to assume that they will be handled by Qt one way or the other and only send mouse events if we can tell that we are not on a touch screen or that the mouse event was not synthesized by WebGL. This was tested on a Windows host with an iPad and Microsoft Edge to verify it works in both cases correctly. Change-Id: Ia2297062b2e1a4894f52954dd567bab5b7df8fa1 Reviewed-by: Jesus Fernandez --- src/plugins/platforms/webgl/webqt.jsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/platforms/webgl/webqt.jsx b/src/plugins/platforms/webgl/webqt.jsx index a3cdede..ca2b3b5 100644 --- a/src/plugins/platforms/webgl/webqt.jsx +++ b/src/plugins/platforms/webgl/webqt.jsx @@ -54,6 +54,8 @@ window.onload = function () { var currentZIndex = 1; var textDecoder; var initialLoadingCanvas; + var supportsTouch = 'ontouchstart' in window || navigator.msMaxTouchPoints; + if (typeof TextDecoder !== 'undefined') { textDecoder = new TextDecoder("utf8"); } else { @@ -227,12 +229,16 @@ window.onload = function () { canvas.onmousedown = function (event) { /* jslint bitwise: true */ + if (supportsTouch && event.mozInputSource == MOZ_SOURCE_TOUCH) + return; qtButtons |= mapButton(event.button); sendMouseEvent(qtButtons, event.layerX, event.layerY, event.clientX, event.clientY, name); }; canvas.onmousemove = function (event) { + if (supportsTouch && event.mozInputSource == MOZ_SOURCE_TOUCH) + return; if (MOUSETRACKING || event.buttons > 0) sendMouseEvent(qtButtons, event.layerX, event.layerY, event.clientX, event.clientY, name); @@ -240,6 +246,8 @@ window.onload = function () { canvas.onmouseup = function (event) { /* jslint bitwise: true */ + if (supportsTouch && event.mozInputSource == MOZ_SOURCE_TOUCH) + return; qtButtons &= ~mapButton(event.button); sendMouseEvent(qtButtons, event.layerX, event.layerY, event.clientX, event.clientY, name); -- cgit v1.2.3