diff --git a/platform/commonUI/browse/bundle.json b/platform/commonUI/browse/bundle.json index 9221ac049d..d9a7b006c3 100644 --- a/platform/commonUI/browse/bundle.json +++ b/platform/commonUI/browse/bundle.json @@ -36,7 +36,7 @@ { "key": "MenuArrowController", "implementation": "MenuArrowController", - "depends": [ "$rootScope" ] + "depends": [ "$rootScope", "$scope" ] } ], "controls": [ @@ -80,7 +80,8 @@ { "key": "menu-arrow", "templateUrl": "templates/menu-arrow.html", - "uses": [ "type" ] + "uses": [ "action" ], + "gestures": [ "menu" ] } ], "services": [ diff --git a/platform/commonUI/browse/src/MenuArrowController.js b/platform/commonUI/browse/src/MenuArrowController.js index 55ae7632c0..7ac009872c 100644 --- a/platform/commonUI/browse/src/MenuArrowController.js +++ b/platform/commonUI/browse/src/MenuArrowController.js @@ -35,12 +35,16 @@ define( * menu. * @constructor */ - function MenuArrowController($rootScope) { + function MenuArrowController($rootScope, $scope) { function contextMenu() { console.log('contextMenu() called'); + //console.log('editor? ', $scope.domainObject.hasCapability('editor')); - $rootScope.$broadcast('contextmenu'); + if (true || $scope.domainObject.hasCapability('editor')) { + //$rootScope.$broadcast('contextmenu'); + $scope.$emit('contextmenu'); + } } return { diff --git a/platform/representation/src/gestures/ContextMenuGesture.js b/platform/representation/src/gestures/ContextMenuGesture.js index 58b08e12b9..70e518fddc 100644 --- a/platform/representation/src/gestures/ContextMenuGesture.js +++ b/platform/representation/src/gestures/ContextMenuGesture.js @@ -51,6 +51,8 @@ define( * in the context menu will be performed */ function ContextMenuGesture($compile, $document, $window, $rootScope, element, domainObject) { + var turnOffMenu; + function showMenu(event) { var winDim = [$window.innerWidth, $window.innerHeight], eventCoors = [event.pageX, event.pageY], @@ -91,10 +93,12 @@ define( "context-menu-holder": true }; - console.log(scope); + console.log("scope ", scope); // Create the context menu menu = $compile(MENU_TEMPLATE)(scope); + + console.log("menu ", menu); // Add the menu to the body body.append(menu); @@ -109,10 +113,10 @@ define( // When context menu event occurs, show object actions instead element.on('contextmenu', showMenu); - // This allows actions besides only right-clicks to trigger a - // context menu - $rootScope.$on('contextmenu', showMenu); - + // This allows actions besides right-clicks to trigger a context menu + // Assigning turnOffMenu to stop multiple pickups of the broadcast + turnOffMenu = $rootScope.$on('contextmenu', showMenu); + return { /** * Detach any event handlers associated with this gesture, @@ -126,6 +130,7 @@ define( dismissExistingMenu(); } element.off('contextmenu', showMenu); + turnOffMenu(); } }; }