thinkmap.contextmenu.ContextMenu

extends:
Jump To: Members Events

A context menu is a menu that with several types of options and actions

Examples:

Construct an context menu with options to center a node as well as collapse and expandn var contextMenu = new thinkmap.contextmenu.ContextMenu(); contextMenu.item('center',"Make Center").onshow(function(evt) { // only make the item visible if an entity exists this.visible(!!evt.entity); }).onaction(function(evt){ // call this function when the user selects this menu option makeCenter(evt.entity); }); contextMenu.item('expand',"Expand").onshow(function(evt) { this.visible(!!evt.entity && evt.entity.isType('node')); // change text of the item depending on if the entity is already // expanded or collapsed this.item(evt.entity.isExpanded ? 'Expand this!' : 'Collapse this!'); }).onaction(function(evt) { // take the appropriate action depending on if the entity is // expanded or collapsed if (evt.entity.isExpanded) { collapse(evt.entity); delete evt.entity.isExpanded; } else { expand(evt.entity); evt.entity.isExpanded = true; } }); display.contextMenu(contextMenu); // bind menu to the display

Constructor

Instance Methods

Defined in thinkmap.contextmenu.ContextMenu:

Events

hide : function ( Event )

this event is fired when the the menu has become hidden

show : function ( Event )

this event is fired when the menu is about to be shown

action : function ( Event )

this event is fired when the user selects an action on the menu