mxEvent

Cross-browser DOM event support.  For internal event handling, mxEventSource and the graph event dispatch loop in mxGraph are used.

Memory Leaks

Use this class for adding and removing listeners to/from DOM nodes.  The removeAllListeners function is provided to remove all listeners that have been added using addListener.  The function should be invoked when the last reference is removed in the JavaScript code, typically when the referenced DOM node is removed from the DOM, and helps to reduce memory leaks in IE6.

Summary
mxEventCross-browser DOM event support.
Variables
objectsContains all objects where any listener was added using addListener.
Functions
addListenerBinds the function to the specified event on the given element.
removeListenerRemoves the specified listener from the given element.
removeAllListenersRemoves all listeners from the given element.
redirectMouseEventsRedirects the mouse events from the given DOM node to the graph dispatch loop using the event and given state as event arguments.
releaseRemoves the known listeners from the given DOM node and its descendants.
disableContextMenuDisables the context menu for the given element.
getSourceReturns the event’s target or srcElement depending on the browser.
isConsumedReturns true if the event has been consumed using consume.
isLeftMouseButtonReturns true if the left mouse button is pressed for the given event.
isRightMouseButtonReturns true if the right mouse button was pressed.
isPopupTriggerReturns true if the event is a popup trigger.
isShiftDownReturns true if the shift key is pressed for the given event.
isAltDownReturns true if the alt key is pressed for the given event.
isControlDownReturns true if the control key is pressed for the given event.
isMetaDownReturns true if the meta key is pressed for the given event.
getMainEventReturns the touch or mouse event that contains the mouse coordinates.
getClientXReturns true if the meta key is pressed for the given event.
getClientYReturns true if the meta key is pressed for the given event.
consumeConsumes the given event.
Variables
LABEL_HANDLEIndex for the label handle in an mxMouseEvent.
MOUSE_DOWNSpecifies the event name for mouseDown.
MOUSE_MOVESpecifies the event name for mouseMove.
MOUSE_UPSpecifies the event name for mouseUp.
ACTIVATESpecifies the event name for activate.
RESIZE_STARTSpecifies the event name for resizeStart.
RESIZESpecifies the event name for resize.
RESIZE_ENDSpecifies the event name for resizeEnd.
MOVE_STARTSpecifies the event name for moveStart.
MOVESpecifies the event name for move.
MOVE_ENDSpecifies the event name for moveEnd.
PAN_STARTSpecifies the event name for panStart.
PANSpecifies the event name for pan.
PAN_ENDSpecifies the event name for panEnd.
MINIMIZESpecifies the event name for minimize.
NORMALIZESpecifies the event name for normalize.
MAXIMIZESpecifies the event name for maximize.
HIDESpecifies the event name for hide.
SHOWSpecifies the event name for show.
CLOSESpecifies the event name for close.
DESTROYSpecifies the event name for destroy.
REFRESHSpecifies the event name for refresh.
SIZESpecifies the event name for size.
SELECTSpecifies the event name for select.
FIREDSpecifies the event name for fired.
GETSpecifies the event name for get.
RECEIVESpecifies the event name for receive.
CONNECTSpecifies the event name for connect.
DISCONNECTSpecifies the event name for disconnect.
SUSPENDSpecifies the event name for suspend.
RESUMESpecifies the event name for suspend.
MARKSpecifies the event name for mark.
SESSIONSpecifies the event name for session.
ROOTSpecifies the event name for root.
POSTSpecifies the event name for post.
OPENSpecifies the event name for open.
SAVESpecifies the event name for open.
BEFORE_ADD_VERTEXSpecifies the event name for beforeAddVertex.
ADD_VERTEXSpecifies the event name for addVertex.
AFTER_ADD_VERTEXSpecifies the event name for afterAddVertex.
DONESpecifies the event name for done.
EXECUTESpecifies the event name for execute.
BEGIN_UPDATESpecifies the event name for beginUpdate.
END_UPDATESpecifies the event name for endUpdate.
BEFORE_UNDOSpecifies the event name for beforeUndo.
UNDOSpecifies the event name for undo.
REDOSpecifies the event name for redo.
CHANGESpecifies the event name for change.
NOTIFYSpecifies the event name for notify.
LAYOUT_CELLSSpecifies the event name for layoutCells.
CLICKSpecifies the event name for click.
SCALESpecifies the event name for scale.
TRANSLATESpecifies the event name for translate.
SCALE_AND_TRANSLATESpecifies the event name for scaleAndTranslate.
UPSpecifies the event name for up.
DOWNSpecifies the event name for down.
ADDSpecifies the event name for add.
CLEARSpecifies the event name for clear.
ADD_CELLSSpecifies the event name for addCells.
CELLS_ADDEDSpecifies the event name for cellsAdded.
MOVE_CELLSSpecifies the event name for moveCells.
CELLS_MOVEDSpecifies the event name for cellsMoved.
RESIZE_CELLSSpecifies the event name for resizeCells.
CELLS_RESIZEDSpecifies the event name for cellsResized.
TOGGLE_CELLSSpecifies the event name for toggleCells.
CELLS_TOGGLEDSpecifies the event name for cellsToggled.
ORDER_CELLSSpecifies the event name for orderCells.
CELLS_ORDEREDSpecifies the event name for cellsOrdered.
REMOVE_CELLSSpecifies the event name for removeCells.
CELLS_REMOVEDSpecifies the event name for cellsRemoved.
GROUP_CELLSSpecifies the event name for groupCells.
UNGROUP_CELLSSpecifies the event name for ungroupCells.
REMOVE_CELLS_FROM_PARENTSpecifies the event name for removeCellsFromParent.
FOLD_CELLSSpecifies the event name for foldCells.
CELLS_FOLDEDSpecifies the event name for cellsFolded.
ALIGN_CELLSSpecifies the event name for alignCells.
LABEL_CHANGEDSpecifies the event name for labelChanged.
CONNECT_CELLSpecifies the event name for connectCell.
CELL_CONNECTEDSpecifies the event name for cellConnected.
SPLIT_EDGESpecifies the event name for splitEdge.
FLIP_EDGESpecifies the event name for flipEdge.
START_EDITINGSpecifies the event name for startEditing.
ADD_OVERLAYSpecifies the event name for addOverlay.
REMOVE_OVERLAYSpecifies the event name for removeOverlay.
UPDATE_CELL_SIZESpecifies the event name for updateCellSize.
ESCAPESpecifies the event name for escape.
CLICKSpecifies the event name for click.
DOUBLE_CLICKSpecifies the event name for doubleClick.

Variables

objects

Contains all objects where any listener was added using addListener.  This is used to reduce memory leaks in IE, see mxClient.dispose.

Functions

addListener

addListener: function()

Binds the function to the specified event on the given element.  Use mxUtils.bind in order to bind the “this” keyword inside the function to a given execution scope.

removeListener

removeListener: function()

Removes the specified listener from the given element.

removeAllListeners

removeAllListeners: function(element)

Removes all listeners from the given element.

redirectMouseEvents

redirectMouseEvents: function(node,
graph,
state,
down,
move,
up,
dblClick)

Redirects the mouse events from the given DOM node to the graph dispatch loop using the event and given state as event arguments.  State can either be an instance of mxCellState or a function that returns an mxCellState.  The down, move, up and dblClick arguments are optional functions that take the trigger event as arguments and replace the default behaviour.

release

release: function(element)

Removes the known listeners from the given DOM node and its descendants.

Parameters

elementDOM node to remove the listeners from.

disableContextMenu

disableContextMenu: function()

Disables the context menu for the given element.

getSource

getSource: function(evt)

Returns the event’s target or srcElement depending on the browser.

isConsumed

isConsumed: function(evt)

Returns true if the event has been consumed using consume.

isLeftMouseButton

isLeftMouseButton: function(evt)

Returns true if the left mouse button is pressed for the given event.  To check if a button is pressed during a mouseMove you should use the mxGraph.isMouseDown property.

isRightMouseButton

isRightMouseButton: function(evt)

Returns true if the right mouse button was pressed.  Note that this button might not be available on some systems.  For handling a popup trigger isPopupTrigger should be used.

isPopupTrigger

isPopupTrigger: function(evt)

Returns true if the event is a popup trigger.  This implementation returns true if the right mouse button or shift was pressed.

isShiftDown

isShiftDown: function(evt)

Returns true if the shift key is pressed for the given event.

isAltDown

isAltDown: function(evt)

Returns true if the alt key is pressed for the given event.

isControlDown

isControlDown: function(evt)

Returns true if the control key is pressed for the given event.

isMetaDown

isMetaDown: function(evt)

Returns true if the meta key is pressed for the given event.

getMainEvent

getMainEvent: function(e)

Returns the touch or mouse event that contains the mouse coordinates.

getClientX

getClientX: function(e)

Returns true if the meta key is pressed for the given event.

getClientY

getClientY: function(e)

Returns true if the meta key is pressed for the given event.

consume

consume: function(evt,
preventDefault,
stopPropagation)

Consumes the given event.

Parameters

evtNative event to be consumed.
preventDefaultOptional boolean to prevent the default for the event.  Default is true.
stopPropagationOption boolean to stop event propagation.  Default is true.

Variables

LABEL_HANDLE

Index for the label handle in an mxMouseEvent.  This should be a negative value that does not interfere with any possible handle indices.  Default is -1.

MOUSE_DOWN

Specifies the event name for mouseDown.

MOUSE_MOVE

Specifies the event name for mouseMove.

MOUSE_UP

Specifies the event name for mouseUp.

ACTIVATE

Specifies the event name for activate.

RESIZE_START

Specifies the event name for resizeStart.

RESIZE

Specifies the event name for resize.

RESIZE_END

Specifies the event name for resizeEnd.

MOVE_START

Specifies the event name for moveStart.

MOVE

Specifies the event name for move.

MOVE_END

Specifies the event name for moveEnd.

PAN_START

Specifies the event name for panStart.

PAN

Specifies the event name for pan.

PAN_END

Specifies the event name for panEnd.

MINIMIZE

Specifies the event name for minimize.

NORMALIZE

Specifies the event name for normalize.

MAXIMIZE

Specifies the event name for maximize.

HIDE

Specifies the event name for hide.

SHOW

Specifies the event name for show.

CLOSE

Specifies the event name for close.

DESTROY

Specifies the event name for destroy.

REFRESH

Specifies the event name for refresh.

SIZE

Specifies the event name for size.

SELECT

Specifies the event name for select.

FIRED

Specifies the event name for fired.

GET

Specifies the event name for get.

RECEIVE

Specifies the event name for receive.

CONNECT

Specifies the event name for connect.

DISCONNECT

Specifies the event name for disconnect.

SUSPEND

Specifies the event name for suspend.

RESUME

Specifies the event name for suspend.

MARK

Specifies the event name for mark.

SESSION

Specifies the event name for session.

ROOT

Specifies the event name for root.

POST

Specifies the event name for post.

OPEN

Specifies the event name for open.

SAVE

Specifies the event name for open.

BEFORE_ADD_VERTEX

Specifies the event name for beforeAddVertex.

ADD_VERTEX

Specifies the event name for addVertex.

AFTER_ADD_VERTEX

Specifies the event name for afterAddVertex.

DONE

Specifies the event name for done.

EXECUTE

Specifies the event name for execute.

BEGIN_UPDATE

Specifies the event name for beginUpdate.

END_UPDATE

Specifies the event name for endUpdate.

BEFORE_UNDO

Specifies the event name for beforeUndo.

UNDO

Specifies the event name for undo.

REDO

Specifies the event name for redo.

CHANGE

Specifies the event name for change.

NOTIFY

Specifies the event name for notify.

LAYOUT_CELLS

Specifies the event name for layoutCells.

CLICK

Specifies the event name for click.

SCALE

Specifies the event name for scale.

TRANSLATE

Specifies the event name for translate.

SCALE_AND_TRANSLATE

Specifies the event name for scaleAndTranslate.

UP

Specifies the event name for up.

DOWN

Specifies the event name for down.

ADD

Specifies the event name for add.

CLEAR

Specifies the event name for clear.

ADD_CELLS

Specifies the event name for addCells.

CELLS_ADDED

Specifies the event name for cellsAdded.

MOVE_CELLS

Specifies the event name for moveCells.

CELLS_MOVED

Specifies the event name for cellsMoved.

RESIZE_CELLS

Specifies the event name for resizeCells.

CELLS_RESIZED

Specifies the event name for cellsResized.

TOGGLE_CELLS

Specifies the event name for toggleCells.

CELLS_TOGGLED

Specifies the event name for cellsToggled.

ORDER_CELLS

Specifies the event name for orderCells.

CELLS_ORDERED

Specifies the event name for cellsOrdered.

REMOVE_CELLS

Specifies the event name for removeCells.

CELLS_REMOVED

Specifies the event name for cellsRemoved.

GROUP_CELLS

Specifies the event name for groupCells.

UNGROUP_CELLS

Specifies the event name for ungroupCells.

REMOVE_CELLS_FROM_PARENT

Specifies the event name for removeCellsFromParent.

FOLD_CELLS

Specifies the event name for foldCells.

CELLS_FOLDED

Specifies the event name for cellsFolded.

ALIGN_CELLS

Specifies the event name for alignCells.

LABEL_CHANGED

Specifies the event name for labelChanged.

CONNECT_CELL

Specifies the event name for connectCell.

CELL_CONNECTED

Specifies the event name for cellConnected.

SPLIT_EDGE

Specifies the event name for splitEdge.

FLIP_EDGE

Specifies the event name for flipEdge.

START_EDITING

Specifies the event name for startEditing.

ADD_OVERLAY

Specifies the event name for addOverlay.

REMOVE_OVERLAY

Specifies the event name for removeOverlay.

UPDATE_CELL_SIZE

Specifies the event name for updateCellSize.

ESCAPE

Specifies the event name for escape.

CLICK

Specifies the event name for click.

DOUBLE_CLICK

DOUBLE_CLICK: 'doubleClick' }

Specifies the event name for doubleClick.

addListener: function()
Binds the function to the specified event on the given element.
removeListener: function()
Removes the specified listener from the given element.
removeAllListeners: function(element)
Removes all listeners from the given element.
redirectMouseEvents: function(node,
graph,
state,
down,
move,
up,
dblClick)
Redirects the mouse events from the given DOM node to the graph dispatch loop using the event and given state as event arguments.
release: function(element)
Removes the known listeners from the given DOM node and its descendants.
disableContextMenu: function()
Disables the context menu for the given element.
getSource: function(evt)
Returns the event’s target or srcElement depending on the browser.
isConsumed: function(evt)
Returns true if the event has been consumed using consume.
consume: function(evt,
preventDefault,
stopPropagation)
Consumes the given event.
isLeftMouseButton: function(evt)
Returns true if the left mouse button is pressed for the given event.
isRightMouseButton: function(evt)
Returns true if the right mouse button was pressed.
isPopupTrigger: function(evt)
Returns true if the event is a popup trigger.
isShiftDown: function(evt)
Returns true if the shift key is pressed for the given event.
isAltDown: function(evt)
Returns true if the alt key is pressed for the given event.
isControlDown: function(evt)
Returns true if the control key is pressed for the given event.
isMetaDown: function(evt)
Returns true if the meta key is pressed for the given event.
getMainEvent: function(e)
Returns the touch or mouse event that contains the mouse coordinates.
getClientX: function(e)
Returns true if the meta key is pressed for the given event.
getClientY: function(e)
Returns true if the meta key is pressed for the given event.
DOUBLE_CLICK: 'doubleClick' }
Specifies the event name for doubleClick.
Base class for objects that dispatch named events.
Extends mxEventSource to implement a graph component for the browser.
dispose: function()
Frees up memory in IE by resolving cyclic dependencies between the DOM and the JavaScript objects.
bind: function(scope,
funct)
Returns a wrapper function that locks the execution scope of the given function to the specified scope.
Represents the current state of a cell in a given mxGraphView.
mxGraph.prototype.isMouseDown
Holds the state of the mouse button.
Close