提交 1af9eab6 编写于 作者: M Matt Bierner

Make sure we restore IgnoreMenuShortcuts on re-focus

Fixes #67879
上级 7e459ec0
...@@ -140,6 +140,9 @@ class SvgBlocker extends Disposable { ...@@ -140,6 +140,9 @@ class SvgBlocker extends Disposable {
} }
class WebviewKeyboardHandler extends Disposable { class WebviewKeyboardHandler extends Disposable {
private _ignoreMenuShortcut = false;
constructor( constructor(
private readonly _webview: Electron.WebviewTag private readonly _webview: Electron.WebviewTag
) { ) {
...@@ -150,8 +153,9 @@ class WebviewKeyboardHandler extends Disposable { ...@@ -150,8 +153,9 @@ 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) => {
if (input.type === 'keyDown') { if (input.type === 'keyDown' && document.activeElement === this._webview) {
this.setIgnoreMenuShortcuts(input.control || input.meta); this._ignoreMenuShortcut = input.control || input.meta;
this.setIgnoreMenuShortcuts(this._ignoreMenuShortcut);
} }
}); });
} }
...@@ -167,6 +171,10 @@ class WebviewKeyboardHandler extends Disposable { ...@@ -167,6 +171,10 @@ class WebviewKeyboardHandler extends Disposable {
this.handleKeydown(event.args[0]); this.handleKeydown(event.args[0]);
return; return;
case 'did-focus':
this.setIgnoreMenuShortcuts(this._ignoreMenuShortcut);
break;
case 'did-blur': case 'did-blur':
this.setIgnoreMenuShortcuts(false); this.setIgnoreMenuShortcuts(false);
return; return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册