提交 31b885de 编写于 作者: B Benjamin Pasero

better fix for global action touch

上级 23ce20da
......@@ -7,6 +7,7 @@
import 'vs/css!./media/activityaction';
import DOM = require('vs/base/browser/dom');
import { EventType as TouchEventType } from 'vs/base/browser/touch';
import { TPromise } from 'vs/base/common/winjs.base';
import { Action } from 'vs/base/common/actions';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
......@@ -107,36 +108,27 @@ export class GlobalActivityActionItem extends ActivityActionItem {
// Context menus are triggered on mouse down so that an item can be picked
// and executed with releasing the mouse over it
this.$container.on(DOM.EventType.MOUSE_DOWN, (e: MouseEvent) => {
this.onClick(e);
DOM.EventHelper.stop(e, true);
const event = new StandardMouseEvent(e);
this.showContextMenu({ x: event.posx, y: event.posy });
});
// Extra listener for keyboard interaction
this.$container.on(DOM.EventType.KEY_UP, (e: KeyboardEvent) => {
let event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.Enter) || event.equals(KeyCode.Space)) {
this.onClick(e);
DOM.EventHelper.stop(e, true);
this.showContextMenu(this.$container.getHTMLElement());
}
});
}
public onClick(event?: MouseEvent | KeyboardEvent): void {
DOM.EventHelper.stop(event, true);
// Prevent duplicate menu showing because we already handle MOUSE_DOWN
// (refs: // https://github.com/Microsoft/vscode/issues/36244)
if (event.type === DOM.EventType.CLICK) {
return;
}
let location: HTMLElement | { x: number, y: number };
if (event instanceof MouseEvent) {
const mouseEvent = new StandardMouseEvent(event);
location = { x: mouseEvent.posx, y: mouseEvent.posy };
} else {
location = this.$container.getHTMLElement();
}
this.$container.on(TouchEventType.Tap, (e: MouseEvent) => {
DOM.EventHelper.stop(e, true);
this.showContextMenu(location);
const event = new StandardMouseEvent(e);
this.showContextMenu({ x: event.posx, y: event.posy });
});
}
private showContextMenu(location: HTMLElement | { x: number, y: number }): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册