diff --git a/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts b/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts index b5d0dfb487679f3223e318998fd76e76eb5d61f2..e02a364582fd136811dc0c9c125483f215b33466 100644 --- a/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts +++ b/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts @@ -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 {