move KeyMouse listeners to correct location

This commit is contained in:
Dimava 2020-06-01 02:36:41 +03:00
parent fe33f51424
commit 0d342ee417
2 changed files with 9 additions and 6 deletions

View File

@ -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);

View File

@ -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;