mxDefaultToolbar

Toolbar for the editor.  This modifies the state of the graph or inserts new cells upon mouse clicks.

Example

Create a toolbar with a button to copy the selection into the clipboard, and a combo box with one action to paste the selection from the clipboard into the graph.

var toolbar = new mxDefaultToolbar(container, editor);
toolbar.addItem('Copy', null, 'copy');

var combo = toolbar.addActionCombo('More actions...');
toolbar.addActionOption(combo, 'Paste', 'paste');

Codec

This class uses the mxDefaultToolbarCodec to read configuration data into an existing instance.  See mxDefaultToolbarCodec for a description of the configuration format.

Summary
mxDefaultToolbarToolbar for the editor.
Functions
mxDefaultToolbarConstructs a new toolbar for the given container and editor.
Variables
editorReference to the enclosing mxEditor.
toolbarHolds the internal mxToolbar.
resetHandlerReference to the function used to reset the toolbar.
spacingDefines the spacing between existing and new vertices in gridSize units when a new vertex is dropped on an existing cell.
connectOnDropSpecifies if elements should be connected if new cells are dropped onto connectable elements.
initConstructs the toolbar for the given container and installs a listener that updates the mxEditor.insertFunction on editor if an item is selected in the toolbar.
Functions
addItemAdds a new item that executes the given action in editor.
addSeparatorAdds a vertical separator using the optional icon.
addComboHelper method to invoke mxToolbar.addCombo on toolbar and return the resulting DOM node.
addActionComboHelper method to invoke <mxToolbar.addActionCombo> on toolbar using the given title and return the resulting DOM node.
addActionOptionBinds the given action to a option with the specified label in the given combo.
addOptionHelper method to invoke mxToolbar.addOption on toolbar and return the resulting DOM node that represents the option.
addModeCreates an item for selecting the given mode in the editor’s graph.
addPrototypeCreates an item for inserting a clone of the specified prototype cell into the editor’s graph.
dropHandles a drop from a toolbar item to the graph.
insertHandles a drop by inserting the given vertex into the given parent cell or the default parent if no parent is specified.
connectHandles a drop by connecting the given vertex to the given source cell.
installDropHandlerMakes the given img draggable using the given function for handling a drop event.
destroyDestroys the toolbar associated with this object and removes all installed listeners.

Functions

mxDefaultToolbar

function mxDefaultToolbar(container,
editor)

Constructs a new toolbar for the given container and editor.  The container and editor may be null if a prototypical instance for a mxDefaultKeyHandlerCodec is created.

Parameters

containerDOM node that contains the toolbar.
editorReference to the enclosing mxEditor.

Variables

editor

mxDefaultToolbar.prototype.editor

Reference to the enclosing mxEditor.

toolbar

mxDefaultToolbar.prototype.toolbar

Holds the internal mxToolbar.

resetHandler

mxDefaultToolbar.prototype.resetHandler

Reference to the function used to reset the toolbar.

spacing

mxDefaultToolbar.prototype.spacing

Defines the spacing between existing and new vertices in gridSize units when a new vertex is dropped on an existing cell.  Default is 4 (40 pixels).

connectOnDrop

mxDefaultToolbar.prototype.connectOnDrop

Specifies if elements should be connected if new cells are dropped onto connectable elements.  Default is false.

init

mxDefaultToolbar.prototype.init

Constructs the toolbar for the given container and installs a listener that updates the mxEditor.insertFunction on editor if an item is selected in the toolbar.  This assumes that editor is not null.

Parameters

containerDOM node that contains the toolbar.

Functions

addItem

mxDefaultToolbar.prototype.addItem = function(title,
icon,
action,
pressed)

Adds a new item that executes the given action in editor.  The title, icon and pressedIcon are used to display the toolbar item.

Parameters

titleString that represents the title (tooltip) for the item.
iconURL of the icon to be used for displaying the item.
actionName of the action to execute when the item is clicked.
pressedOptional URL of the icon for the pressed state.

addSeparator

mxDefaultToolbar.prototype.addSeparator = function(icon)

Adds a vertical separator using the optional icon.

Parameters

iconOptional URL of the icon that represents the vertical separator.  Default is mxClient.imageBasePath + ‘/separator.gif’.

addCombo

mxDefaultToolbar.prototype.addCombo = function()

Helper method to invoke mxToolbar.addCombo on toolbar and return the resulting DOM node.

addActionCombo

mxDefaultToolbar.prototype.addActionCombo = function(title)

Helper method to invoke <mxToolbar.addActionCombo> on toolbar using the given title and return the resulting DOM node.

Parameters

titleString that represents the title of the combo.

addActionOption

mxDefaultToolbar.prototype.addActionOption = function(combo,
title,
action)

Binds the given action to a option with the specified label in the given combo.  Combo is an object returned from an earlier call to addCombo or addActionCombo.

Parameters

comboDOM node that represents the combo box.
titleString that represents the title of the combo.
actionName of the action to execute in editor.

addOption

mxDefaultToolbar.prototype.addOption = function(combo,
title,
value)

Helper method to invoke mxToolbar.addOption on toolbar and return the resulting DOM node that represents the option.

Parameters

comboDOM node that represents the combo box.
titleString that represents the title of the combo.
valueObject that represents the value of the option.

addMode

mxDefaultToolbar.prototype.addMode = function(title,
icon,
mode,
pressed,
funct)

Creates an item for selecting the given mode in the editor’s graph.  Supported modenames are select, connect and pan.

Parameters

titleString that represents the title of the item.
iconURL of the icon that represents the item.
modeString that represents the mode name to be used in mxEditor.setMode.
pressedOptional URL of the icon that represents the pressed state.
functOptional JavaScript function that takes the mxEditor as the first and only argument that is executed after the mode has been selected.

addPrototype

mxDefaultToolbar.prototype.addPrototype = function(title,
icon,
ptype,
pressed,
insert,
toggle)

Creates an item for inserting a clone of the specified prototype cell into the editor’s graph.  The ptype may either be a cell or a function that returns a cell.

Parameters

titleString that represents the title of the item.
iconURL of the icon that represents the item.
ptypeFunction or object that represents the prototype cell.  If ptype is a function then it is invoked with no arguments to create new instances.
pressedOptional URL of the icon that represents the pressed state.
insertOptional JavaScript function that handles an insert of the new cell.  This function takes the mxEditor, new cell to be inserted, mouse event and optional mxCell under the mouse pointer as arguments.
toggleOptional boolean that specifies if the item can be toggled.  Default is true.

drop

mxDefaultToolbar.prototype.drop = function(vertex,
evt,
target)

Handles a drop from a toolbar item to the graph.  The given vertex represents the new cell to be inserted.  This invokes insert or connect depending on the given target cell.

Parameters

vertexmxCell to be inserted.
evtMouse event that represents the drop.
targetOptional mxCell that represents the drop target.

insert

mxDefaultToolbar.prototype.insert = function(vertex,
evt,
target)

Handles a drop by inserting the given vertex into the given parent cell or the default parent if no parent is specified.

Parameters

vertexmxCell to be inserted.
evtMouse event that represents the drop.
parentOptional mxCell that represents the parent.

connect

mxDefaultToolbar.prototype.connect = function(vertex,
evt,
source)

Handles a drop by connecting the given vertex to the given source cell.

vertexmxCell to be inserted.
evtMouse event that represents the drop.
sourceOptional mxCell that represents the source terminal.

installDropHandler

mxDefaultToolbar.prototype.installDropHandler = function (img,
dropHandler)

Makes the given img draggable using the given function for handling a drop event.

Parameters

imgDOM node that represents the image.
dropHandlerFunction that handles a drop of the image.

destroy

mxDefaultToolbar.prototype.destroy = function ()

Destroys the toolbar associated with this object and removes all installed listeners.  This does normally not need to be called, the toolbar is destroyed automatically when the window unloads (in IE) by mxEditor.

function mxDefaultToolbar(container,
editor)
Constructs a new toolbar for the given container and editor.
mxDefaultToolbar.prototype.editor
Reference to the enclosing mxEditor.
Extends mxEventSource to implement a application wrapper for a graph that adds actions, I/O using mxCodec, auto-layout using mxLayoutManager, command history using undoManager, and standard dialogs and widgets, eg.
mxDefaultToolbar.prototype.toolbar
Holds the internal mxToolbar.
Creates a toolbar inside a given DOM node.
mxDefaultToolbar.prototype.resetHandler
Reference to the function used to reset the toolbar.
mxDefaultToolbar.prototype.spacing
Defines the spacing between existing and new vertices in gridSize units when a new vertex is dropped on an existing cell.
mxDefaultToolbar.prototype.connectOnDrop
Specifies if elements should be connected if new cells are dropped onto connectable elements.
mxDefaultToolbar.prototype.init
Constructs the toolbar for the given container and installs a listener that updates the mxEditor.insertFunction on editor if an item is selected in the toolbar.
mxEditor.prototype.insertFunction
Specifies the function to be used for inserting new cells into the graph.
mxDefaultToolbar.prototype.addItem = function(title,
icon,
action,
pressed)
Adds a new item that executes the given action in editor.
mxDefaultToolbar.prototype.addSeparator = function(icon)
Adds a vertical separator using the optional icon.
mxDefaultToolbar.prototype.addCombo = function()
Helper method to invoke mxToolbar.addCombo on toolbar and return the resulting DOM node.
mxToolbar.prototype.addCombo = function(style)
Adds and returns a new SELECT element using the given style.
mxDefaultToolbar.prototype.addActionCombo = function(title)
Helper method to invoke mxToolbar.addActionCombo on toolbar using the given title and return the resulting DOM node.
mxDefaultToolbar.prototype.addActionOption = function(combo,
title,
action)
Binds the given action to a option with the specified label in the given combo.
mxDefaultToolbar.prototype.addOption = function(combo,
title,
value)
Helper method to invoke mxToolbar.addOption on toolbar and return the resulting DOM node that represents the option.
mxToolbar.prototype.addOption = function(combo,
title,
value)
Adds and returns a new OPTION element inside the given SELECT element.
mxDefaultToolbar.prototype.addMode = function(title,
icon,
mode,
pressed,
funct)
Creates an item for selecting the given mode in the editor’s graph.
mxDefaultToolbar.prototype.addPrototype = function(title,
icon,
ptype,
pressed,
insert,
toggle)
Creates an item for inserting a clone of the specified prototype cell into the editor’s graph.
mxDefaultToolbar.prototype.drop = function(vertex,
evt,
target)
Handles a drop from a toolbar item to the graph.
mxDefaultToolbar.prototype.insert = function(vertex,
evt,
target)
Handles a drop by inserting the given vertex into the given parent cell or the default parent if no parent is specified.
mxDefaultToolbar.prototype.connect = function(vertex,
evt,
source)
Handles a drop by connecting the given vertex to the given source cell.
mxDefaultToolbar.prototype.installDropHandler = function (img,
dropHandler)
Makes the given img draggable using the given function for handling a drop event.
mxDefaultToolbar.prototype.destroy = function ()
Destroys the toolbar associated with this object and removes all installed listeners.
Custom codec for configuring mxDefaultToolbars.
Custom codec for configuring mxDefaultKeyHandlers.
Basepath for all images URLs in the core without trailing slash.
mxEditor.prototype.setMode = function(modename)
Puts the graph into the specified mode.
Cells are the elements of the graph model.
Close