Skip to content

Commit ef0f5f5

Browse files
committed
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 <[email protected]>
1 parent 63a47ff commit ef0f5f5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/plugins/platforms/webgl/webqt.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ window.onload = function () {
5454
var currentZIndex = 1;
5555
var textDecoder;
5656
var initialLoadingCanvas;
57+
var supportsTouch = 'ontouchstart' in window || navigator.msMaxTouchPoints;
58+
5759
if (typeof TextDecoder !== 'undefined') {
5860
textDecoder = new TextDecoder("utf8");
5961
} else {
@@ -227,19 +229,25 @@ window.onload = function () {
227229

228230
canvas.onmousedown = function (event) {
229231
/* jslint bitwise: true */
232+
if (supportsTouch && event.mozInputSource == MOZ_SOURCE_TOUCH)
233+
return;
230234
qtButtons |= mapButton(event.button);
231235
sendMouseEvent(qtButtons, event.layerX, event.layerY, event.clientX, event.clientY,
232236
name);
233237
};
234238

235239
canvas.onmousemove = function (event) {
240+
if (supportsTouch && event.mozInputSource == MOZ_SOURCE_TOUCH)
241+
return;
236242
if (MOUSETRACKING || event.buttons > 0)
237243
sendMouseEvent(qtButtons, event.layerX, event.layerY, event.clientX, event.clientY,
238244
name);
239245
};
240246

241247
canvas.onmouseup = function (event) {
242248
/* jslint bitwise: true */
249+
if (supportsTouch && event.mozInputSource == MOZ_SOURCE_TOUCH)
250+
return;
243251
qtButtons &= ~mapButton(event.button);
244252
sendMouseEvent(qtButtons, event.layerX, event.layerY, event.clientX, event.clientY,
245253
name);

0 commit comments

Comments
 (0)