mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
move KeyMouse listeners to correct location
This commit is contained in:
parent
fe33f51424
commit
0d342ee417
@ -141,8 +141,13 @@ export class InputDistributor {
|
|||||||
bindToEvents() {
|
bindToEvents() {
|
||||||
window.addEventListener("popstate", this.handleBackButton.bind(this), false);
|
window.addEventListener("popstate", this.handleBackButton.bind(this), false);
|
||||||
document.addEventListener("backbutton", this.handleBackButton.bind(this), false);
|
document.addEventListener("backbutton", this.handleBackButton.bind(this), false);
|
||||||
window.addEventListener("keydown", this.handleKeydown.bind(this));
|
|
||||||
window.addEventListener("keyup", this.handleKeyup.bind(this));
|
window.addEventListener("keydown", this.handleKeyMouseDown.bind(this));
|
||||||
|
window.addEventListener("keyup", this.handleKeyMouseUp.bind(this));
|
||||||
|
|
||||||
|
window.addEventListener("mousedown", this.handleKeyMouseDown.bind(this));
|
||||||
|
window.addEventListener("mouseup", this.handleKeyMouseUp.bind(this));
|
||||||
|
|
||||||
window.addEventListener("blur", this.handleBlur.bind(this));
|
window.addEventListener("blur", this.handleBlur.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +189,7 @@ export class InputDistributor {
|
|||||||
/**
|
/**
|
||||||
* @param {KeyboardEvent | MouseEvent} event
|
* @param {KeyboardEvent | MouseEvent} event
|
||||||
*/
|
*/
|
||||||
handleKeydown(event) {
|
handleKeyMouseDown(event) {
|
||||||
const keyCode = event instanceof MouseEvent ? event.button + 1 : event.keyCode;
|
const keyCode = event instanceof MouseEvent ? event.button + 1 : event.keyCode;
|
||||||
if (
|
if (
|
||||||
keyCode === 4 || // MB4
|
keyCode === 4 || // MB4
|
||||||
@ -224,7 +229,7 @@ export class InputDistributor {
|
|||||||
/**
|
/**
|
||||||
* @param {KeyboardEvent | MouseEvent} event
|
* @param {KeyboardEvent | MouseEvent} event
|
||||||
*/
|
*/
|
||||||
handleKeyup(event) {
|
handleKeyMouseUp(event) {
|
||||||
const keyCode = event instanceof MouseEvent ? event.button + 1 : event.keyCode;
|
const keyCode = event instanceof MouseEvent ? event.button + 1 : event.keyCode;
|
||||||
this.keysDown.delete(keyCode);
|
this.keysDown.delete(keyCode);
|
||||||
|
|
||||||
|
@ -443,7 +443,6 @@ export class Camera extends BasicSerializableObject {
|
|||||||
} else if (event.button === 2) {
|
} else if (event.button === 2) {
|
||||||
this.downPreHandler.dispatch(new Vector(event.clientX, event.clientY), enumMouseButton.right);
|
this.downPreHandler.dispatch(new Vector(event.clientX, event.clientY), enumMouseButton.right);
|
||||||
}
|
}
|
||||||
this.root.app.inputMgr.handleKeydown(event);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,7 +484,6 @@ export class Camera extends BasicSerializableObject {
|
|||||||
if (!this.checkPreventDoubleMouse()) {
|
if (!this.checkPreventDoubleMouse()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.root.app.inputMgr.handleKeyup(event);
|
|
||||||
|
|
||||||
this.combinedSingleTouchStopHandler(event.clientX, event.clientY);
|
this.combinedSingleTouchStopHandler(event.clientX, event.clientY);
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user