add focus title bar command (#155347)

fixes #149739
This commit is contained in:
SteVen Batten 2022-07-15 18:06:33 -07:00 committed by GitHub
parent 015d6b8e62
commit cad5e069b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,6 +36,7 @@ import { WindowTitle } from 'vs/workbench/browser/parts/titlebar/windowTitle';
import { CommandCenterControl } from 'vs/workbench/browser/parts/titlebar/commandCenterControl';
import { IHoverDelegate } from 'vs/base/browser/ui/iconLabel/iconHoverDelegate';
import { IHoverService } from 'vs/workbench/services/hover/browser/hover';
import { CATEGORIES } from 'vs/workbench/common/actions';
export class TitlebarPart extends Part implements ITitleService {
@ -328,6 +329,27 @@ export class TitlebarPart extends Part implements ITitleService {
this.updateStyles();
const that = this;
registerAction2(class FocusTitleBar extends Action2 {
constructor() {
super({
id: `workbench.action.focusTitleBar`,
title: { value: localize('focusTitleBar', "Focus Title Bar"), original: 'Focus Title Bar' },
category: CATEGORIES.View,
f1: true,
});
}
run(accessor: ServicesAccessor, ...args: any[]): void {
if (that.customMenubar) {
that.customMenubar.toggleFocus();
} else {
(that.element.querySelector('[tabindex]:not([tabindex="-1"])') as HTMLElement).focus();
}
}
});
return this.element;
}