Skip to content

Commit ec42f2a

Browse files
authored
Merge pull request microsoft#186647 from microsoft/merogge/cmd-e
allow turning on accessibility help from within the help menu
2 parents ed9fc30 + e6ed074 commit ec42f2a

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/vs/workbench/contrib/accessibility/browser/accessibleView.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { AccessibilityHelpNLS } from 'vs/editor/common/standaloneStrings';
1616
import { LinkDetector } from 'vs/editor/contrib/links/browser/links';
1717
import { localize } from 'vs/nls';
1818
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
19+
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
1920
import { IContextViewDelegate, IContextViewService } from 'vs/platform/contextview/browser/contextView';
2021
import { IInstantiationService, createDecorator } from 'vs/platform/instantiation/common/instantiation';
2122
import { IOpenerService } from 'vs/platform/opener/common/opener';
@@ -56,20 +57,23 @@ export interface IAccessibleViewOptions {
5657
type: AccessibleViewType;
5758
}
5859

60+
export const accessibilityHelpIsShown = new RawContextKey<boolean>('accessibilityHelpIsShown', false, true);
5961
class AccessibleView extends Disposable {
6062
private _editorWidget: CodeEditorWidget;
63+
private _accessiblityHelpIsShown: IContextKey<boolean>;
6164
get editorWidget() { return this._editorWidget; }
6265
private _editorContainer: HTMLElement;
6366
private _keyListener: IDisposable | undefined;
64-
6567
constructor(
6668
@IOpenerService private readonly _openerService: IOpenerService,
6769
@IInstantiationService private readonly _instantiationService: IInstantiationService,
6870
@IConfigurationService private readonly _configurationService: IConfigurationService,
6971
@IModelService private readonly _modelService: IModelService,
70-
@IContextViewService private readonly _contextViewService: IContextViewService
72+
@IContextViewService private readonly _contextViewService: IContextViewService,
73+
@IContextKeyService private readonly _contextKeyService: IContextKeyService
7174
) {
7275
super();
76+
this._accessiblityHelpIsShown = accessibilityHelpIsShown.bindTo(this._contextKeyService);
7377
this._editorContainer = document.createElement('div');
7478
this._editorContainer.classList.add('accessible-view');
7579
const codeEditorWidgetOptions: ICodeEditorWidgetOptions = {
@@ -96,9 +100,17 @@ class AccessibleView extends Disposable {
96100
getAnchor: () => this._editorContainer,
97101
render: (container) => {
98102
return this._render(provider, container);
103+
},
104+
onHide: () => {
105+
if (provider.options.type === AccessibleViewType.HelpMenu) {
106+
this._accessiblityHelpIsShown.reset();
107+
}
99108
}
100109
};
101110
this._contextViewService.showContextView(delegate);
111+
if (provider.options.type === AccessibleViewType.HelpMenu) {
112+
this._accessiblityHelpIsShown.set(true);
113+
}
102114
}
103115

104116
private _render(provider: IAccessibleContentProvider, container: HTMLElement): IDisposable {

src/vs/workbench/contrib/codeEditor/browser/accessibility/accessibility.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
2626
import { AccessibilitySupport, IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
2727
import { Action2, registerAction2 } from 'vs/platform/actions/common/actions';
2828
import { TabFocus, TabFocusContext } from 'vs/editor/browser/config/tabFocus';
29+
import { accessibilityHelpIsShown } from 'vs/workbench/contrib/accessibility/browser/accessibleView';
30+
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
2931

3032
const CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE = new RawContextKey<boolean>('accessibilityHelpWidgetVisible', false);
3133

@@ -279,6 +281,11 @@ class ToggleScreenReaderMode extends Action2 {
279281
id: 'editor.action.toggleScreenReaderAccessibilityMode',
280282
title: { value: nls.localize('toggleScreenReaderMode', "Toggle Screen Reader Accessibility Mode"), original: 'Toggle Screen Reader Accessibility Mode' },
281283
f1: true,
284+
keybinding: {
285+
primary: KeyMod.CtrlCmd | KeyCode.KeyE,
286+
weight: KeybindingWeight.WorkbenchContrib + 10,
287+
when: accessibilityHelpIsShown
288+
}
282289
});
283290
}
284291

0 commit comments

Comments
 (0)