mxPopupMenu

Basic popup menu.  To add a vertical scrollbar to a given submenu, the following code can be used.

var mxPopupMenuShowMenu = mxPopupMenu.prototype.showMenu;
mxPopupMenu.prototype.showMenu = function()
{
  mxPopupMenuShowMenu.apply(this, arguments);

  this.div.style.overflowY = 'auto';
  this.div.style.overflowX = 'hidden';
  this.div.style.maxHeight = '160px';
};
Summary
mxPopupMenuBasic popup menu.
Functions
mxPopupMenuConstructs a popupmenu.
Events
mxEvent.SHOWFires after the menu has been shown in popup.
Variables
submenuImageURL of the image to be used for the submenu icon.
zIndexSpecifies the zIndex for the popupmenu and its shadow.
factoryMethodFunction that is used to create the popup menu.
useLeftButtonForPopupSpecifies if popupmenus should be activated by clicking the left mouse button.
enabledSpecifies if events are handled.
itemCountContains the number of times addItem has been called for a new menu.
autoExpandSpecifies if submenus should be expanded on mouseover.
smartSeparatorsSpecifies if separators should only be added if a menu item follows them.
labelsSpecifies if any labels should be visible.
Functions
initInitializes the shapes required for this vertex handler.
isEnabledReturns true if events are handled.
setEnabledEnables or disables event handling.
isPopupTriggerReturns true if the given event is a popupmenu trigger for the optional given cell.
addItemAdds the given item to the given parent item.
createSubmenuCreates the nodes required to add submenu items inside the given parent item.
showSubmenuShows the submenu inside the given parent row.
addSeparatorAdds a horizontal separator in the given parent item or the top-level menu if no parent is specified.
popupShows the popup menu for the given event and cell.
isMenuShowingReturns true if the menu is showing.
showMenuShows the menu.
hideMenuRemoves the menu and all submenus.
hideSubmenuRemoves all submenus inside the given parent.
destroyDestroys the handler and all its resources and DOM nodes.

Functions

mxPopupMenu

Constructs a popupmenu.

Events

mxEvent.SHOW

Fires after the menu has been shown in popup.

Variables

submenuImage

mxPopupMenu.prototype.submenuImage

URL of the image to be used for the submenu icon.

zIndex

mxPopupMenu.prototype.zIndex

Specifies the zIndex for the popupmenu and its shadow.  Default is 10006.

factoryMethod

mxPopupMenu.prototype.factoryMethod

Function that is used to create the popup menu.  The function takes the current panning handler, the mxCell under the mouse and the mouse event that triggered the call as arguments.

useLeftButtonForPopup

mxPopupMenu.prototype.useLeftButtonForPopup

Specifies if popupmenus should be activated by clicking the left mouse button.  Default is false.

enabled

mxPopupMenu.prototype.enabled

Specifies if events are handled.  Default is true.

itemCount

mxPopupMenu.prototype.itemCount

Contains the number of times addItem has been called for a new menu.

autoExpand

mxPopupMenu.prototype.autoExpand

Specifies if submenus should be expanded on mouseover.  Default is false.

smartSeparators

mxPopupMenu.prototype.smartSeparators

Specifies if separators should only be added if a menu item follows them.  Default is false.

labels

mxPopupMenu.prototype.labels

Specifies if any labels should be visible.  Default is true.

Functions

init

mxPopupMenu.prototype.init = function()

Initializes the shapes required for this vertex handler.

isEnabled

mxPopupMenu.prototype.isEnabled = function()

Returns true if events are handled.  This implementation returns enabled.

setEnabled

mxPopupMenu.prototype.setEnabled = function(enabled)

Enables or disables event handling.  This implementation updates enabled.

isPopupTrigger

mxPopupMenu.prototype.isPopupTrigger = function(me)

Returns true if the given event is a popupmenu trigger for the optional given cell.

Parameters

memxMouseEvent that represents the mouse event.

addItem

mxPopupMenu.prototype.addItem = function(title,
image,
funct,
parent,
iconCls,
enabled,
active,
noHover)

Adds the given item to the given parent item.  If no parent item is specified then the item is added to the top-level menu.  The return value may be used as the parent argument, ie. as a submenu item.  The return value is the table row that represents the item.

Paramters

titleString that represents the title of the menu item.
imageOptional URL for the image icon.
functFunction associated that takes a mouseup or touchend event.
parentOptional item returned by addItem.
iconClsOptional string that represents the CSS class for the image icon.  IconsCls is ignored if image is given.
enabledOptional boolean indicating if the item is enabled.  Default is true.
activeOptional boolean indicating if the menu should implement any event handling.  Default is true.
noHoverOptional boolean to disable hover state.

createSubmenu

mxPopupMenu.prototype.createSubmenu = function(parent)

Creates the nodes required to add submenu items inside the given parent item.  This is called in addItem if a parent item is used for the first time.  This adds various DOM nodes and a submenuImage to the parent.

Parameters

parentAn item returned by addItem.

showSubmenu

mxPopupMenu.prototype.showSubmenu = function(parent,
row)

Shows the submenu inside the given parent row.

addSeparator

mxPopupMenu.prototype.addSeparator = function(parent,
force)

Adds a horizontal separator in the given parent item or the top-level menu if no parent is specified.

Parameters

parentOptional item returned by addItem.
forceOptional boolean to ignore smartSeparators.  Default is false.

popup

mxPopupMenu.prototype.popup = function(x,
y,
cell,
evt)

Shows the popup menu for the given event and cell.

Example

graph.panningHandler.popup = function(x, y, cell, evt)
{
  mxUtils.alert('Hello, World!');
}

isMenuShowing

mxPopupMenu.prototype.isMenuShowing = function()

Returns true if the menu is showing.

showMenu

mxPopupMenu.prototype.showMenu = function()

Shows the menu.

hideMenu

mxPopupMenu.prototype.hideMenu = function()

Removes the menu and all submenus.

hideSubmenu

mxPopupMenu.prototype.hideSubmenu = function(parent)

Removes all submenus inside the given parent.

Parameters

parentAn item returned by addItem.

destroy

mxPopupMenu.prototype.destroy = function()

Destroys the handler and all its resources and DOM nodes.

mxPopupMenu.prototype.popup = function(x,
y,
cell,
evt)
Shows the popup menu for the given event and cell.
mxPopupMenu.prototype.submenuImage
URL of the image to be used for the submenu icon.
mxPopupMenu.prototype.zIndex
Specifies the zIndex for the popupmenu and its shadow.
mxPopupMenu.prototype.factoryMethod
Function that is used to create the popup menu.
mxPopupMenu.prototype.useLeftButtonForPopup
Specifies if popupmenus should be activated by clicking the left mouse button.
mxPopupMenu.prototype.enabled
Specifies if events are handled.
mxPopupMenu.prototype.itemCount
Contains the number of times addItem has been called for a new menu.
mxPopupMenu.prototype.addItem = function(title,
image,
funct,
parent,
iconCls,
enabled,
active,
noHover)
Adds the given item to the given parent item.
mxPopupMenu.prototype.autoExpand
Specifies if submenus should be expanded on mouseover.
mxPopupMenu.prototype.smartSeparators
Specifies if separators should only be added if a menu item follows them.
mxPopupMenu.prototype.labels
Specifies if any labels should be visible.
mxPopupMenu.prototype.init = function()
Initializes the shapes required for this vertex handler.
mxPopupMenu.prototype.isEnabled = function()
Returns true if events are handled.
mxPopupMenu.prototype.setEnabled = function(enabled)
Enables or disables event handling.
mxPopupMenu.prototype.isPopupTrigger = function(me)
Returns true if the given event is a popupmenu trigger for the optional given cell.
mxPopupMenu.prototype.createSubmenu = function(parent)
Creates the nodes required to add submenu items inside the given parent item.
mxPopupMenu.prototype.showSubmenu = function(parent,
row)
Shows the submenu inside the given parent row.
mxPopupMenu.prototype.addSeparator = function(parent,
force)
Adds a horizontal separator in the given parent item or the top-level menu if no parent is specified.
mxPopupMenu.prototype.isMenuShowing = function()
Returns true if the menu is showing.
mxPopupMenu.prototype.showMenu = function()
Shows the menu.
mxPopupMenu.prototype.hideMenu = function()
Removes the menu and all submenus.
mxPopupMenu.prototype.hideSubmenu = function(parent)
Removes all submenus inside the given parent.
mxPopupMenu.prototype.destroy = function()
Destroys the handler and all its resources and DOM nodes.
Cells are the elements of the graph model.
Base class for all mouse events in mxGraph.
Close