fix: 修复兼容报错

This commit is contained in:
liujuping 2022-12-13 17:26:51 +08:00
parent 080102db5b
commit c88dfda955
3 changed files with 10 additions and 1 deletions

View File

@ -368,10 +368,16 @@ export class Hotkey {
private nextExpectedAction: boolean | string = false; private nextExpectedAction: boolean | string = false;
private isActivate = true;
constructor(readonly name: string = 'unknown') { constructor(readonly name: string = 'unknown') {
this.mount(window); this.mount(window);
} }
activate(activate: boolean): void {
this.isActivate = activate;
}
mount(window: Window) { mount(window: Window) {
const { document } = window; const { document } = window;
const handleKeyEvent = this.handleKeyEvent.bind(this); const handleKeyEvent = this.handleKeyEvent.bind(this);
@ -546,6 +552,9 @@ export class Hotkey {
} }
private handleKeyEvent(e: KeyboardEvent): void { private handleKeyEvent(e: KeyboardEvent): void {
if (!this.isActivate) {
return;
}
const character = characterFromEvent(e); const character = characterFromEvent(e);
// no character found then stop // no character found then stop

View File

@ -80,7 +80,6 @@ export class BasicContext {
editor.set('material', material); editor.set('material', material);
editor.set('hotkey', hotkey); editor.set('hotkey', hotkey);
editor.set('innerHotkey', innerHotkey); editor.set('innerHotkey', innerHotkey);
innerHotkey.mount(window);
this.innerSetters = innerSetters; this.innerSetters = innerSetters;
this.innerSkeleton = innerSkeleton; this.innerSkeleton = innerSkeleton;
this.skeleton = skeleton; this.skeleton = skeleton;

View File

@ -16,6 +16,7 @@ export class Context extends BasicContext {
setActivate = (_activate: boolean) => { setActivate = (_activate: boolean) => {
this._activate = _activate; this._activate = _activate;
this.innerHotkey.activate(this._activate);
}; };
get active() { get active() {