refactor: forward key events
This commit is contained in:
parent
5df58532dc
commit
f3a82e9385
|
@ -44,6 +44,8 @@ export class Stage extends decorate(Container) {
|
|||
// Normalize input.
|
||||
this.inputNormalizer = new InputNormalizer();
|
||||
this.inputNormalizer.listen(this.element);
|
||||
this.inputNormalizer.on('keyDown', this.onKeyDown, this);
|
||||
this.inputNormalizer.on('keyUp', this.onKeyUp, this);
|
||||
this.inputNormalizer.on('pointerDown', this.onPointerDown, this);
|
||||
this.inputNormalizer.on('pointerMove', this.onPointerMove, this);
|
||||
this.inputNormalizer.on('pointerUp', this.onPointerUp, this);
|
||||
|
@ -86,9 +88,11 @@ export class Stage extends decorate(Container) {
|
|||
if (this.parent) {
|
||||
this.parent.removeChild(this.renderer.element);
|
||||
}
|
||||
this.inputNormalizer.off('pointerDown', this.onPointerDown, this);
|
||||
this.inputNormalizer.off('pointerMove', this.onPointerMove, this);
|
||||
this.inputNormalizer.off('pointerUp', this.onPointerUp, this);
|
||||
this.inputNormalizer.off('keyDown', this.onKeyDown);
|
||||
this.inputNormalizer.off('keyUp', this.onKeyUp);
|
||||
this.inputNormalizer.off('pointerDown', this.onPointerDown);
|
||||
this.inputNormalizer.off('pointerMove', this.onPointerMove);
|
||||
this.inputNormalizer.off('pointerUp', this.onPointerUp);
|
||||
this.inputNormalizer.destroy();
|
||||
}
|
||||
|
||||
|
@ -128,6 +132,14 @@ export class Stage extends decorate(Container) {
|
|||
this.element.focus();
|
||||
}
|
||||
|
||||
onKeyDown(event) {
|
||||
this.emit('keyDown', event);
|
||||
}
|
||||
|
||||
onKeyUp(event) {
|
||||
this.emit('keyUp', event);
|
||||
}
|
||||
|
||||
onPointerDown(event) {
|
||||
event.position = this.transformCanvasPosition(event.position);
|
||||
this.emit('pointerDown', event);
|
||||
|
|
Loading…
Reference in New Issue
Block a user