|
@@ -60,6 +60,9 @@ export class InputManager {
|
|
|
/** If you need to check double click without raising a single click at first click, enable this flag */
|
|
|
public static ExclusiveDoubleClickMode = false;
|
|
|
|
|
|
+ /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
|
|
|
+ private _alreadyAttached = false;
|
|
|
+
|
|
|
// Pointers
|
|
|
private _wheelEventName = "";
|
|
|
private _onPointerMove: (evt: PointerEvent) => void;
|
|
@@ -458,6 +461,9 @@ export class InputManager {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ if (this._alreadyAttached) {
|
|
|
+ this.detachControl();
|
|
|
+ }
|
|
|
let engine = scene.getEngine();
|
|
|
|
|
|
this._initActionManager = (act: Nullable<AbstractActionManager>, clickInfo: _ClickInfo): Nullable<AbstractActionManager> => {
|
|
@@ -817,6 +823,7 @@ export class InputManager {
|
|
|
hostWindow.addEventListener(eventPrefix + "up", <any>this._onPointerUp, false);
|
|
|
}
|
|
|
}
|
|
|
+ this._alreadyAttached = true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -831,6 +838,10 @@ export class InputManager {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ if (!this._alreadyAttached) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// Pointer
|
|
|
canvas.removeEventListener(eventPrefix + "move", <any>this._onPointerMove);
|
|
|
canvas.removeEventListener(this._wheelEventName, <any>this._onPointerMove);
|
|
@@ -854,6 +865,8 @@ export class InputManager {
|
|
|
if (!this._scene.doNotHandleCursors) {
|
|
|
canvas.style.cursor = this._scene.defaultCursor;
|
|
|
}
|
|
|
+
|
|
|
+ this._alreadyAttached = false;
|
|
|
}
|
|
|
|
|
|
/**
|