diff --git a/src/vs/base/browser/ui/menu/menubar.ts b/src/vs/base/browser/ui/menu/menubar.ts index f4506d877b5196908762082943369cbb91147630..2cf359db3be4409ee97ef18f8e438eddddc89fe5 100644 --- a/src/vs/base/browser/ui/menu/menubar.ts +++ b/src/vs/base/browser/ui/menu/menubar.ts @@ -446,6 +446,16 @@ export class MenuBar extends Disposable { return this.container.clientHeight; } + toggleFocus(): void { + if (!this.isFocused && this.options.visibility !== 'hidden') { + this.mnemonicsInUse = true; + this.focusedMenu = { index: this.numMenusShown > 0 ? 0 : MenuBar.OVERFLOW_INDEX }; + this.focusState = MenubarState.FOCUSED; + } else if (!this.isOpen) { + this.setUnfocusedState(); + } + } + private updateOverflowAction(): void { if (!this.menuCache || !this.menuCache.length) { return; diff --git a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts index e7fdf3898d5f930a63cbac8df4d3b5baa8e9169c..1b2f52c6ab78d0cf4248ad3bfa0f1cd3c78dd7e7 100644 --- a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts +++ b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as nls from 'vs/nls'; -import { IMenuService, MenuId, IMenu, SubmenuItemAction } from 'vs/platform/actions/common/actions'; +import { IMenuService, MenuId, IMenu, SubmenuItemAction, registerAction2, Action2 } from 'vs/platform/actions/common/actions'; import { registerThemingParticipant, IColorTheme, ICssStyleCollector, IThemeService } from 'vs/platform/theme/common/themeService'; import { MenuBarVisibility, getTitleBarStyle, IWindowOpenable, getMenuBarVisibility } from 'vs/platform/windows/common/windows'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; @@ -35,6 +35,9 @@ import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/la import { isFullscreen } from 'vs/base/browser/browser'; import { IHostService } from 'vs/workbench/services/host/browser/host'; import { BrowserFeatures } from 'vs/base/browser/canIUse'; +import { KeyCode } from 'vs/base/common/keyCodes'; +import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { IsWebContext } from 'vs/platform/contextkey/common/contextkeys'; export abstract class MenubarControl extends Disposable { @@ -312,6 +315,8 @@ export class CustomMenubarControl extends MenubarControl { this.registerListeners(); + this.registerActions(); + registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) => { const menubarActiveWindowFgColor = theme.getColor(TITLE_BAR_ACTIVE_FOREGROUND); if (menubarActiveWindowFgColor) { @@ -411,6 +416,32 @@ export class CustomMenubarControl extends MenubarControl { this.setupCustomMenubar(firstTime); } + private registerActions(): void { + const that = this; + + if (isWeb) { + this._register(registerAction2(class extends Action2 { + constructor() { + super({ + id: `workbench.actions.menubar.focus`, + title: { value: nls.localize('focusMenu', "Focus Application Menu"), original: 'Focus Application Menu' }, + keybinding: { + primary: KeyCode.F10, + weight: KeybindingWeight.WorkbenchContrib, + when: IsWebContext + } + }); + } + + async run(): Promise { + if (that.menubar) { + that.menubar.toggleFocus(); + } + } + })); + } + } + private getUpdateAction(): IAction | null { const state = this.updateService.state;