提交 48cc02be 编写于 作者: M Matt Bierner

Extract setIgnoreMenuShortcuts

上级 3cdcfa85
...@@ -157,7 +157,7 @@ class WebviewKeyboardHandler extends Disposable { ...@@ -157,7 +157,7 @@ class WebviewKeyboardHandler extends Disposable {
const contents = this.getWebContents(); const contents = this.getWebContents();
if (contents) { if (contents) {
contents.on('before-input-event', (_event, input) => { contents.on('before-input-event', (_event, input) => {
contents.setIgnoreMenuShortcuts(input.control || input.meta); this.setIgnoreMenuShortcuts(input.control || input.meta);
}); });
} }
})); }));
...@@ -173,12 +173,7 @@ class WebviewKeyboardHandler extends Disposable { ...@@ -173,12 +173,7 @@ class WebviewKeyboardHandler extends Disposable {
return; return;
case 'did-blur': case 'did-blur':
if (this.shouldToggleMenuShortcutsEnablement) { this.setIgnoreMenuShortcuts(false);
const contents = this.getWebContents();
if (contents) {
contents.setIgnoreMenuShortcuts(false);
}
}
return; return;
} }
})); }));
...@@ -188,6 +183,16 @@ class WebviewKeyboardHandler extends Disposable { ...@@ -188,6 +183,16 @@ class WebviewKeyboardHandler extends Disposable {
return isMacintosh; return isMacintosh;
} }
private setIgnoreMenuShortcuts(value: boolean) {
if (!this.shouldToggleMenuShortcutsEnablement) {
return;
}
const contents = this.getWebContents();
if (contents) {
contents.setIgnoreMenuShortcuts(value);
}
}
private getWebContents(): Electron.WebContents | undefined { private getWebContents(): Electron.WebContents | undefined {
const contents = this._webview.getWebContents(); const contents = this._webview.getWebContents();
if (contents && !contents.isDestroyed()) { if (contents && !contents.isDestroyed()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册