@@ -28,6 +28,8 @@ import { IThemeService, ITheme, registerThemingParticipant, ICssStyleCollector }
2828import { ACTIVITY_BAR_BADGE_FOREGROUND , ACTIVITY_BAR_BADGE_BACKGROUND , ACTIVITY_BAR_DRAG_AND_DROP_BACKGROUND , ACTIVITY_BAR_FOREGROUND } from 'vs/workbench/common/theme' ;
2929import { contrastBorder , activeContrastBorder , focusBorder } from 'vs/platform/theme/common/colorRegistry' ;
3030import { StandardMouseEvent } from "vs/base/browser/mouseEvent" ;
31+ import { KeyCode } from "vs/base/common/keyCodes" ;
32+ import { StandardKeyboardEvent } from "vs/base/browser/keyboardEvent" ;
3133
3234export interface IViewletActivity {
3335 badge : IBadge ;
@@ -669,17 +671,35 @@ export class GlobalActivityActionItem extends ActivityActionItem {
669671 super ( action , { draggable : false } , themeService ) ;
670672 }
671673
672- public onClick ( e : MouseEvent ) : void {
674+ public render ( container : HTMLElement ) : void {
675+ super . render ( container ) ;
676+
677+ // Context menus are triggered on mouse down so that an item can be picked
678+ // and executed with releasing the mouse over it
679+ this . $container . on ( DOM . EventType . MOUSE_DOWN , ( e : MouseEvent ) => {
680+ DOM . EventHelper . stop ( e , true ) ;
681+
682+ const event = new StandardMouseEvent ( e ) ;
683+ this . showContextMenu ( { x : event . posx , y : event . posy } ) ;
684+ } ) ;
685+
686+ this . $container . on ( DOM . EventType . KEY_UP , ( e : KeyboardEvent ) => {
687+ let event = new StandardKeyboardEvent ( e ) ;
688+ if ( event . equals ( KeyCode . Enter ) || event . equals ( KeyCode . Space ) ) {
689+ DOM . EventHelper . stop ( e , true ) ;
690+
691+ this . showContextMenu ( this . $container . getHTMLElement ( ) ) ;
692+ }
693+ } ) ;
694+ }
695+
696+ private showContextMenu ( location : HTMLElement | { x : number , y : number } ) : void {
673697 const globalAction = this . _action as GlobalActivityAction ;
674698 const activity = globalAction . activity as IGlobalActivity ;
675699 const actions = activity . getActions ( ) ;
676700
677- const event = new StandardMouseEvent ( e ) ;
678- event . stopPropagation ( ) ;
679- event . preventDefault ( ) ;
680-
681701 this . contextMenuService . showContextMenu ( {
682- getAnchor : ( ) => ( { x : event . posx , y : event . posy } ) ,
702+ getAnchor : ( ) => location ,
683703 getActions : ( ) => TPromise . as ( actions ) ,
684704 onHide : ( ) => dispose ( actions )
685705 } ) ;
0 commit comments