提交 0e86dd63 编写于 作者: J Johannes Rieken

MenuItemActionItem only listens to alt-key when having an alt-command

上级 68174933
...@@ -128,14 +128,16 @@ export class MenuItemActionItem extends ActionItem { ...@@ -128,14 +128,16 @@ export class MenuItemActionItem extends ActionItem {
private _wantsAltCommand: boolean; private _wantsAltCommand: boolean;
private _itemClassDispose: IDisposable; private _itemClassDispose: IDisposable;
private readonly _altKey: AlternativeKeyEmitter;
constructor( constructor(
public _action: MenuItemAction, readonly _action: MenuItemAction,
@IKeybindingService private readonly _keybindingService: IKeybindingService, @IKeybindingService private readonly _keybindingService: IKeybindingService,
@INotificationService protected _notificationService: INotificationService, @INotificationService protected _notificationService: INotificationService,
@IContextMenuService private readonly _contextMenuService: IContextMenuService @IContextMenuService _contextMenuService: IContextMenuService
) { ) {
super(undefined, _action, { icon: !!(_action.class || _action.item.iconLocation), label: !_action.class && !_action.item.iconLocation }); super(undefined, _action, { icon: !!(_action.class || _action.item.iconLocation), label: !_action.class && !_action.item.iconLocation });
this._altKey = AlternativeKeyEmitter.getInstance(_contextMenuService);
} }
protected get _commandAction(): IAction { protected get _commandAction(): IAction {
...@@ -146,9 +148,8 @@ export class MenuItemActionItem extends ActionItem { ...@@ -146,9 +148,8 @@ export class MenuItemActionItem extends ActionItem {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
const altKey = AlternativeKeyEmitter.getInstance(this._contextMenuService); if (this._altKey.isPressed) {
if (altKey.isPressed) { this._altKey.suppressAltKeyUp();
altKey.suppressAltKeyUp();
} }
this.actionRunner.run(this._commandAction) this.actionRunner.run(this._commandAction)
...@@ -161,8 +162,8 @@ export class MenuItemActionItem extends ActionItem { ...@@ -161,8 +162,8 @@ export class MenuItemActionItem extends ActionItem {
this._updateItemClass(this._action.item); this._updateItemClass(this._action.item);
let mouseOver = false; let mouseOver = false;
const alternativeKeyEmitter = AlternativeKeyEmitter.getInstance(this._contextMenuService);
let alternativeKeyDown = alternativeKeyEmitter.isPressed; let alternativeKeyDown = this._altKey.isPressed;
const updateAltState = () => { const updateAltState = () => {
const wantsAltCommand = mouseOver && alternativeKeyDown; const wantsAltCommand = mouseOver && alternativeKeyDown;
...@@ -174,10 +175,12 @@ export class MenuItemActionItem extends ActionItem { ...@@ -174,10 +175,12 @@ export class MenuItemActionItem extends ActionItem {
} }
}; };
this._register(alternativeKeyEmitter.event(value => { if (this._action.alt) {
alternativeKeyDown = value; this._register(this._altKey.event(value => {
updateAltState(); alternativeKeyDown = value;
})); updateAltState();
}));
}
this._register(domEvent(container, 'mouseleave')(_ => { this._register(domEvent(container, 'mouseleave')(_ => {
mouseOver = false; mouseOver = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册