mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 23:28:14 +00:00
[Browse] Stopped multiple broadcasts
Stopped the menu arrow from making multiple broadcasts of contextmenu. #33.
This commit is contained in:
@ -36,7 +36,7 @@
|
|||||||
{
|
{
|
||||||
"key": "MenuArrowController",
|
"key": "MenuArrowController",
|
||||||
"implementation": "MenuArrowController",
|
"implementation": "MenuArrowController",
|
||||||
"depends": [ "$rootScope" ]
|
"depends": [ "$rootScope", "$scope" ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"controls": [
|
"controls": [
|
||||||
@ -80,7 +80,8 @@
|
|||||||
{
|
{
|
||||||
"key": "menu-arrow",
|
"key": "menu-arrow",
|
||||||
"templateUrl": "templates/menu-arrow.html",
|
"templateUrl": "templates/menu-arrow.html",
|
||||||
"uses": [ "type" ]
|
"uses": [ "action" ],
|
||||||
|
"gestures": [ "menu" ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"services": [
|
"services": [
|
||||||
|
@ -35,12 +35,16 @@ define(
|
|||||||
* menu.
|
* menu.
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function MenuArrowController($rootScope) {
|
function MenuArrowController($rootScope, $scope) {
|
||||||
|
|
||||||
function contextMenu() {
|
function contextMenu() {
|
||||||
console.log('contextMenu() called');
|
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 {
|
return {
|
||||||
|
@ -51,6 +51,8 @@ define(
|
|||||||
* in the context menu will be performed
|
* in the context menu will be performed
|
||||||
*/
|
*/
|
||||||
function ContextMenuGesture($compile, $document, $window, $rootScope, element, domainObject) {
|
function ContextMenuGesture($compile, $document, $window, $rootScope, element, domainObject) {
|
||||||
|
var turnOffMenu;
|
||||||
|
|
||||||
function showMenu(event) {
|
function showMenu(event) {
|
||||||
var winDim = [$window.innerWidth, $window.innerHeight],
|
var winDim = [$window.innerWidth, $window.innerHeight],
|
||||||
eventCoors = [event.pageX, event.pageY],
|
eventCoors = [event.pageX, event.pageY],
|
||||||
@ -91,10 +93,12 @@ define(
|
|||||||
"context-menu-holder": true
|
"context-menu-holder": true
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(scope);
|
console.log("scope ", scope);
|
||||||
|
|
||||||
// Create the context menu
|
// Create the context menu
|
||||||
menu = $compile(MENU_TEMPLATE)(scope);
|
menu = $compile(MENU_TEMPLATE)(scope);
|
||||||
|
|
||||||
|
console.log("menu ", menu);
|
||||||
|
|
||||||
// Add the menu to the body
|
// Add the menu to the body
|
||||||
body.append(menu);
|
body.append(menu);
|
||||||
@ -109,10 +113,10 @@ define(
|
|||||||
// When context menu event occurs, show object actions instead
|
// When context menu event occurs, show object actions instead
|
||||||
element.on('contextmenu', showMenu);
|
element.on('contextmenu', showMenu);
|
||||||
|
|
||||||
// This allows actions besides only right-clicks to trigger a
|
// This allows actions besides right-clicks to trigger a context menu
|
||||||
// context menu
|
// Assigning turnOffMenu to stop multiple pickups of the broadcast
|
||||||
$rootScope.$on('contextmenu', showMenu);
|
turnOffMenu = $rootScope.$on('contextmenu', showMenu);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
* Detach any event handlers associated with this gesture,
|
* Detach any event handlers associated with this gesture,
|
||||||
@ -126,6 +130,7 @@ define(
|
|||||||
dismissExistingMenu();
|
dismissExistingMenu();
|
||||||
}
|
}
|
||||||
element.off('contextmenu', showMenu);
|
element.off('contextmenu', showMenu);
|
||||||
|
turnOffMenu();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user