Fix stuck moving when window looses focus. Fixes: #408

This commit is contained in:
Lukas Rieger (Blue) 2023-06-17 11:53:39 +02:00
parent 0f7fd4ccd4
commit 4fc6d7f889
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
6 changed files with 46 additions and 0 deletions

View File

@ -66,11 +66,13 @@ export class KeyHeightControls {
window.addEventListener("keydown", this.onKeyDown);
window.addEventListener("keyup", this.onKeyUp);
window.addEventListener("blur", this.onStop)
}
stop() {
window.removeEventListener("keydown", this.onKeyDown);
window.removeEventListener("keyup", this.onKeyUp);
window.removeEventListener("blur", this.onStop)
}
/**
@ -120,4 +122,9 @@ export class KeyHeightControls {
}
}
onStop = evt => {
this.up = false;
this.down = false;
}
}

View File

@ -78,11 +78,13 @@ export class KeyMoveControls {
window.addEventListener("keydown", this.onKeyDown);
window.addEventListener("keyup", this.onKeyUp);
window.addEventListener("blur", this.onStop)
}
stop() {
window.removeEventListener("keydown", this.onKeyDown);
window.removeEventListener("keyup", this.onKeyUp);
window.removeEventListener("blur", this.onStop)
}
/**
@ -152,4 +154,11 @@ export class KeyMoveControls {
}
}
onStop = evt => {
this.up = false;
this.down = false;
this.left = false;
this.right = false;
}
}

View File

@ -67,11 +67,13 @@ export class KeyAngleControls {
window.addEventListener("keydown", this.onKeyDown);
window.addEventListener("keyup", this.onKeyUp);
window.addEventListener("blur", this.onStop)
}
stop() {
window.removeEventListener("keydown", this.onKeyDown);
window.removeEventListener("keyup", this.onKeyUp);
window.removeEventListener("blur", this.onStop)
}
/**
@ -121,4 +123,9 @@ export class KeyAngleControls {
}
}
onStop = evt => {
this.up = false;
this.down = false;
}
}

View File

@ -78,11 +78,13 @@ export class KeyMoveControls {
window.addEventListener("keydown", this.onKeyDown);
window.addEventListener("keyup", this.onKeyUp);
window.addEventListener("blur", this.onStop)
}
stop() {
window.removeEventListener("keydown", this.onKeyDown);
window.removeEventListener("keyup", this.onKeyUp);
window.removeEventListener("blur", this.onStop)
}
/**
@ -152,4 +154,11 @@ export class KeyMoveControls {
}
}
onStop = evt => {
this.up = false;
this.down = false;
this.left = false;
this.right = false;
}
}

View File

@ -67,11 +67,13 @@ export class KeyRotateControls {
window.addEventListener("keydown", this.onKeyDown);
window.addEventListener("keyup", this.onKeyUp);
window.addEventListener("blur", this.onStop)
}
stop() {
window.removeEventListener("keydown", this.onKeyDown);
window.removeEventListener("keyup", this.onKeyUp);
window.removeEventListener("blur", this.onStop)
}
/**
@ -121,4 +123,9 @@ export class KeyRotateControls {
}
}
onStop = evt => {
this.left = false;
this.right = false;
}
}

View File

@ -65,11 +65,13 @@ export class KeyZoomControls {
window.addEventListener("keydown", this.onKeyDown);
window.addEventListener("keyup", this.onKeyUp);
window.addEventListener("blur", this.onStop)
}
stop() {
window.removeEventListener("keydown", this.onKeyDown);
window.removeEventListener("keyup", this.onKeyUp);
window.removeEventListener("blur", this.onStop)
}
/**
@ -119,4 +121,9 @@ export class KeyZoomControls {
}
}
onStop = evt => {
this.in = false;
this.out = false;
}
}