提交 27f3b675 编写于 作者: S SteVen Batten

fixes #75703

上级 f7db1dcc
......@@ -18,6 +18,7 @@ import { KeyCode, ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { Disposable, dispose, IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
import { withNullAsUndefined } from 'vs/base/common/types';
import { asArray } from 'vs/base/common/arrays';
import { ScanCodeUtils, ScanCode } from 'vs/base/common/scanCode';
const $ = DOM.$;
......@@ -777,6 +778,13 @@ export class MenuBar extends Disposable {
return;
}
// Prevent alt-key default if the menu is not hidden and we use alt to focus
if (modifierKeyStatus.event && !this.options.disableAltFocus) {
if (ScanCodeUtils.toEnum(modifierKeyStatus.event.code) === ScanCode.AltLeft) {
modifierKeyStatus.event.preventDefault();
}
}
// Alt key pressed while menu is focused. This should return focus away from the menubar
if (this.isFocused && modifierKeyStatus.lastKeyPressed === 'alt' && modifierKeyStatus.altKey) {
this.setUnfocusedState();
......@@ -892,6 +900,7 @@ interface IModifierKeyStatus {
ctrlKey: boolean;
lastKeyPressed?: ModifierKey;
lastKeyReleased?: ModifierKey;
event?: KeyboardEvent;
}
......@@ -930,6 +939,7 @@ class ModifierKeyEmitter extends Emitter<IModifierKeyStatus> {
this._keyStatus.shiftKey = e.shiftKey;
if (this._keyStatus.lastKeyPressed) {
this._keyStatus.event = e;
this.fire(this._keyStatus);
}
}));
......@@ -954,6 +964,7 @@ class ModifierKeyEmitter extends Emitter<IModifierKeyStatus> {
this._keyStatus.shiftKey = e.shiftKey;
if (this._keyStatus.lastKeyReleased) {
this._keyStatus.event = e;
this.fire(this._keyStatus);
}
}));
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import { Registry } from 'vs/platform/registry/common/platform';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
import { isWindows, isLinux } from 'vs/base/common/platform';
// Configuration
(function registerConfiguration(): void {
const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
// Window
registry.registerConfiguration({
'id': 'window',
'order': 8,
'title': nls.localize('windowConfigurationTitle', "Window"),
'type': 'object',
'properties': {
'window.menuBarVisibility': {
'type': 'string',
'enum': ['default', 'visible', 'toggle', 'hidden'],
'enumDescriptions': [
nls.localize('window.menuBarVisibility.default', "Menu is only hidden in full screen mode."),
nls.localize('window.menuBarVisibility.visible', "Menu is always visible even in full screen mode."),
nls.localize('window.menuBarVisibility.toggle', "Menu is hidden but can be displayed via Alt key."),
nls.localize('window.menuBarVisibility.hidden', "Menu is always hidden.")
],
'default': 'default',
'scope': ConfigurationScope.APPLICATION,
'description': nls.localize('menuBarVisibility', "Control the visibility of the menu bar. A setting of 'toggle' means that the menu bar is hidden and a single press of the Alt key will show it. By default, the menu bar will be visible, unless the window is full screen."),
'included': isWindows || isLinux
},
'window.enableMenuBarMnemonics': {
'type': 'boolean',
'default': true,
'scope': ConfigurationScope.APPLICATION,
'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
}
}
});
})();
\ No newline at end of file
......@@ -34,6 +34,8 @@ import { assign } from 'vs/base/common/objects';
import { mnemonicMenuLabel, unmnemonicLabel } from 'vs/base/common/labels';
import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
import { withNullAsUndefined } from 'vs/base/common/types';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { isFullscreen } from 'vs/base/browser/browser';
export abstract class MenubarControl extends Disposable {
......@@ -106,8 +108,6 @@ export abstract class MenubarControl extends Disposable {
this.menuUpdater = this._register(new RunOnceScheduler(() => this.doUpdateMenubar(false), 200));
this.notifyUserOfCustomMenubarAccessibility();
this.registerListeners();
}
protected abstract doUpdateMenubar(firstTime: boolean): void;
......@@ -300,6 +300,8 @@ export class NativeMenubarControl extends MenubarControl {
this.doUpdateMenubar(true);
});
this.registerListeners();
}
protected doUpdateMenubar(firstTime: boolean): void {
......@@ -457,7 +459,8 @@ export class CustomMenubarControl extends MenubarControl {
@IPreferencesService preferencesService: IPreferencesService,
@IEnvironmentService environmentService: IEnvironmentService,
@IAccessibilityService accessibilityService: IAccessibilityService,
@IThemeService private readonly themeService: IThemeService
@IThemeService private readonly themeService: IThemeService,
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService
) {
super(
......@@ -482,6 +485,8 @@ export class CustomMenubarControl extends MenubarControl {
this.recentlyOpened = recentlyOpened;
});
this.registerListeners();
registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
const menubarActiveWindowFgColor = theme.getColor(TITLE_BAR_ACTIVE_FOREGROUND);
if (menubarActiveWindowFgColor) {
......@@ -642,7 +647,7 @@ export class CustomMenubarControl extends MenubarControl {
enableMenuBarMnemonics = true;
}
return enableMenuBarMnemonics;
return enableMenuBarMnemonics && (!isWeb || isFullscreen());
}
private setupCustomMenubar(firstTime: boolean): void {
......@@ -750,6 +755,11 @@ export class CustomMenubarControl extends MenubarControl {
this._register(DOM.addDisposableListener(window, DOM.EventType.RESIZE, () => {
this.menubar.blur();
}));
// Mnemonics require fullscreen in web
if (isWeb) {
this._register(this.layoutService.onFullscreenChange(e => this.updateMenubar()));
}
}
get onVisibilityChange(): Event<boolean> {
......
......@@ -9,7 +9,7 @@ import 'vs/editor/editor.all';
import 'vs/workbench/api/browser/extensionHost.contribution';
// import 'vs/workbench/electron-browser/main.contribution';
import 'vs/workbench/browser/main.contribution';
import 'vs/workbench/browser/workbench.contribution';
import 'vs/workbench/browser/web.main';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册