diff --git a/srcjs/stendhal/ui/ViewPort.ts b/srcjs/stendhal/ui/ViewPort.ts index 0b1ddeaa07b..257227dc44d 100644 --- a/srcjs/stendhal/ui/ViewPort.ts +++ b/srcjs/stendhal/ui/ViewPort.ts @@ -21,7 +21,6 @@ import { ActionContextMenu } from "./dialog/ActionContextMenu"; import { DropQuantitySelectorDialog } from "./dialog/DropQuantitySelectorDialog"; import { DirectionPad } from "./joystick/DirectionPad"; -import { Joystick } from "./joystick/Joystick"; import { JoystickBase } from "./joystick/JoystickBase"; import { singletons } from "../SingletonRepo"; @@ -308,7 +307,7 @@ export class ViewPort { const mHandle: any = {}; mHandle._onMouseDown = function(e: MouseEvent|TouchEvent) { - if (e instanceof TouchEvent) { + if (window['TouchEvent'] && e instanceof TouchEvent) { stendhal.ui.touch.onTouchStart(); } var pos = stendhal.ui.html.extractPosition(e); @@ -352,13 +351,13 @@ export class ViewPort { } mHandle.onMouseUp = function(e: MouseEvent|TouchEvent) { - if (e instanceof TouchEvent) { + if (window['TouchEvent'] && e instanceof TouchEvent) { stendhal.ui.touch.onTouchEnd(); } var pos = stendhal.ui.html.extractPosition(e); const long_touch = stendhal.ui.touch.isLongTouch(); if ((e instanceof MouseEvent && mHandle.isRightClick(e) - || (e instanceof TouchEvent && long_touch))) { + || (window['TouchEvent'] && e instanceof TouchEvent && long_touch))) { if (entity != stendhal.zone.ground) { const append: any[] = []; if (long_touch) { @@ -506,7 +505,7 @@ export class ViewPort { // item was dropped stendhal.ui.heldItem = undefined; - const is_touch = e instanceof TouchEvent; + const is_touch = window['TouchEvent'] && e instanceof TouchEvent; // if ctrl is pressed or is a touch event, we ask for the quantity if (e.ctrlKey || is_touch) { ui.createSingletonFloatingWindow("Quantity", new DropQuantitySelectorDialog(action, is_touch), pos.pageX - 50, pos.pageY - 25); diff --git a/srcjs/stendhal/ui/component/ItemContainerImplementation.ts b/srcjs/stendhal/ui/component/ItemContainerImplementation.ts index 1defbfa17a9..f840b02ea65 100644 --- a/srcjs/stendhal/ui/component/ItemContainerImplementation.ts +++ b/srcjs/stendhal/ui/component/ItemContainerImplementation.ts @@ -274,7 +274,7 @@ export class ItemContainerImplementation { const long_touch = stendhal.ui.touch.isLongTouch(); if (this.isRightClick(event) || long_touch) { const append = []; - if (evt instanceof TouchEvent && long_touch) { + if (window['TouchEvent'] && evt instanceof TouchEvent && long_touch) { // XXX: better way to pass instance to action function? const tmp = this; // action to "hold" item for moving or dropping using touch