提交 1739c99c 编写于 作者: J Johannes Rieken

make sure ALT doesn't stick, #8435

上级 a3324574
......@@ -54,19 +54,16 @@ const _altKey = new class extends Emitter<boolean> {
private _subscriptions: IDisposable[] = [];
constructor() {
super({
onFirstListenerAdd: () => {
domEvent(document.body, 'keydown')(this._key, this, this._subscriptions);
domEvent(document.body, 'keyup')(this._key, this, this._subscriptions);
},
onLastListenerRemove: () => {
this._subscriptions = dispose(this._subscriptions);
}
});
super();
this._subscriptions.push(domEvent(document.body, 'keydown')(e => this.fire(e.altKey)));
this._subscriptions.push(domEvent(document.body, 'keyup')(e => this.fire(false)));
this._subscriptions.push(domEvent(document.body, 'mouseleave')(e => this.fire(false)));
}
private _key(e: KeyboardEvent) {
this.fire(e.type === 'keydown' && e.altKey);
dispose() {
super.dispose();
this._subscriptions = dispose(this._subscriptions);
}
};
......@@ -102,21 +99,25 @@ class MenuItemActionItem extends ActionItem {
let altSubscription: IDisposable;
let mouseOver: boolean;
this._callOnDispose.push(domEvent(container, 'mouseleave')(_ => {
mouseOver = false;
if (!this._altKeyDown) {
dispose(altSubscription);
// stop listen on ALT
altSubscription.dispose();
}
mouseOver = false;
}));
this._callOnDispose.push(domEvent(container, 'mouseenter')(e => {
mouseOver = true;
altSubscription = _altKey.event(value => {
if (!mouseOver) {
dispose(altSubscription);
}
this._altKeyDown = value;
this._updateLabel();
this._updateTooltip();
this._updateClass();
if (!mouseOver) {
// stop listening on ALT
altSubscription.dispose();
}
});
}));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册