提交 1151dab2 编写于 作者: E Evgeny Zakharov 提交者: SteVen Batten

add window.disableMenuBarAltBehavior option (#73258)

* add window.disableMenuBarAltBehavior option

* enable alt behavior when menuBarVisibility is set to 'toggle'

* rename 'window.disableMenuBarAltBehavior' to 'window.disableCustomMenuBarAltBehavior' and change its description

* don't affect mnemonics
上级 3509f35d
......@@ -23,6 +23,7 @@ const $ = DOM.$;
export interface IMenuBarOptions {
enableMnemonics?: boolean;
disableAltFocus?: boolean;
visibility?: string;
getKeybinding?: (action: IAction) => ResolvedKeybinding | undefined;
alwaysOnMnemonics?: boolean;
......@@ -786,7 +787,7 @@ export class MenuBar extends Disposable {
// Clean alt key press and release
if (allModifiersReleased && modifierKeyStatus.lastKeyPressed === 'alt' && modifierKeyStatus.lastKeyReleased === 'alt') {
if (!this.awaitingAltRelease) {
if (!this.isFocused) {
if (!this.isFocused && !(this.options.disableAltFocus && this.options.visibility !== 'toggle')) {
this.mnemonicsInUse = true;
this.focusedMenu = { index: this.numMenusShown > 0 ? 0 : MenuBar.OVERFLOW_INDEX };
this.focusState = MenubarState.FOCUSED;
......
......@@ -40,6 +40,7 @@ export abstract class MenubarControl extends Disposable {
protected keys = [
'window.menuBarVisibility',
'window.enableMenuBarMnemonics',
'window.disableCustomMenuBarAltFocus',
'window.nativeTabs'
];
......@@ -603,6 +604,15 @@ export class CustomMenubarControl extends MenubarControl {
return this.configurationService.getValue<MenuBarVisibility>('window.menuBarVisibility');
}
private get currentDisableMenuBarAltFocus(): boolean {
let disableMenuBarAltBehavior = this.configurationService.getValue<boolean>('window.disableCustomMenuBarAltFocus');
if (typeof disableMenuBarAltBehavior !== 'boolean') {
disableMenuBarAltBehavior = false;
}
return disableMenuBarAltBehavior;
}
private insertActionsBefore(nextAction: IAction, target: IAction[]): void {
switch (nextAction.id) {
case 'workbench.action.openRecent':
......@@ -640,6 +650,7 @@ export class CustomMenubarControl extends MenubarControl {
this.menubar = this._register(new MenuBar(
this.container, {
enableMnemonics: this.currentEnableMenuBarMnemonics,
disableAltFocus: this.currentDisableMenuBarAltFocus,
visibility: this.currentMenubarVisibility,
getKeybinding: (action) => this.keybindingService.lookupKeybinding(action.id),
}
......@@ -647,7 +658,7 @@ export class CustomMenubarControl extends MenubarControl {
this.accessibilityService.alwaysUnderlineAccessKeys().then(val => {
this.alwaysOnMnemonics = val;
this.menubar.update({ enableMnemonics: this.currentEnableMenuBarMnemonics, visibility: this.currentMenubarVisibility, getKeybinding: (action) => this.keybindingService.lookupKeybinding(action.id), alwaysOnMnemonics: this.alwaysOnMnemonics });
this.menubar.update({ enableMnemonics: this.currentEnableMenuBarMnemonics, disableAltFocus: this.currentDisableMenuBarAltFocus, visibility: this.currentMenubarVisibility, getKeybinding: (action) => this.keybindingService.lookupKeybinding(action.id), alwaysOnMnemonics: this.alwaysOnMnemonics });
});
this._register(this.menubar.onFocusStateChange(e => this._onFocusStateChange.fire(e)));
......@@ -655,7 +666,7 @@ export class CustomMenubarControl extends MenubarControl {
this._register(attachMenuStyler(this.menubar, this.themeService));
} else {
this.menubar.update({ enableMnemonics: this.currentEnableMenuBarMnemonics, visibility: this.currentMenubarVisibility, getKeybinding: (action) => this.keybindingService.lookupKeybinding(action.id), alwaysOnMnemonics: this.alwaysOnMnemonics });
this.menubar.update({ enableMnemonics: this.currentEnableMenuBarMnemonics, disableAltFocus: this.currentDisableMenuBarAltFocus, visibility: this.currentMenubarVisibility, getKeybinding: (action) => this.keybindingService.lookupKeybinding(action.id), alwaysOnMnemonics: this.alwaysOnMnemonics });
}
// Update the menu actions
......@@ -774,7 +785,7 @@ export class CustomMenubarControl extends MenubarControl {
}
if (this.menubar) {
this.menubar.update({ enableMnemonics: this.currentEnableMenuBarMnemonics, visibility: this.currentMenubarVisibility, getKeybinding: (action) => this.keybindingService.lookupKeybinding(action.id), alwaysOnMnemonics: this.alwaysOnMnemonics });
this.menubar.update({ enableMnemonics: this.currentEnableMenuBarMnemonics, disableAltFocus: this.currentDisableMenuBarAltFocus, visibility: this.currentMenubarVisibility, getKeybinding: (action) => this.keybindingService.lookupKeybinding(action.id), alwaysOnMnemonics: this.alwaysOnMnemonics });
}
}
}
......@@ -623,6 +623,13 @@ import product from 'vs/platform/product/node/product';
'description': nls.localize('enableMenuBarMnemonics', "If enabled, the main menus can be opened via Alt-key shortcuts. Disabling mnemonics allows to bind these Alt-key shortcuts to editor commands instead."),
'included': isWindows || isLinux
},
'window.disableCustomMenuBarAltFocus': {
'type': 'boolean',
'default': false,
'scope': ConfigurationScope.APPLICATION,
'markdownDescription': nls.localize('disableCustomMenuBarAltFocus', "If enabled, disables the ability to focus the menu bar with the Alt-key when not set to toggle."),
'included': isWindows || isLinux
},
'window.autoDetectHighContrast': {
'type': 'boolean',
'default': true,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册