diff options
author | Andy Shaw <andy.shaw@qt.io> | 2019-11-21 12:18:28 +0100 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2019-11-22 10:12:57 +0100 |
commit | ef0f5f5ed8cdb6dd70f728fd1873158785f43d27 (patch) | |
tree | 2086994cb5ba32a4a030db8036701923dbe50828 /src/plugins | |
parent | 63a47ff1f83c64e6865edd61657ad1d636fcae23 (diff) |
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 <jsfdez@gmail.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/webgl/webqt.jsx | 8 |
1 files changed, 8 insertions, 0 deletions
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); |