Cross-browser DOM event support. For internal event handling, mxEventSource and the graph event dispatch loop in mxGraph are used.
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.
mxEvent | Cross-browser DOM event support. |
Functions | |
addListener | Binds the function to the specified event on the given element. |
removeListener | Removes the specified listener from the given element. |
removeAllListeners | Removes all listeners from the given element. |
addGestureListeners | Adds the given listeners for touch, mouse and/or pointer events. |
removeGestureListeners | Removes the given listeners from mousedown, mousemove, mouseup and the respective touch events if mxClient.IS_TOUCH is true. |
redirectMouseEvents | Redirects the mouse events from the given DOM node to the graph dispatch loop using the event and given state as event arguments. |
release | Removes the known listeners from the given DOM node and its descendants. |
disableContextMenu | Disables the context menu for the given element. |
getSource | Returns the event’s target or srcElement depending on the browser. |
isConsumed | Returns true if the event has been consumed using consume. |
isTouchEvent | Returns true if the event was generated using a touch device (not a pen or mouse). |
isPenEvent | Returns true if the event was generated using a pen (not a touch device or mouse). |
isMultiTouchEvent | Returns true if the event was generated using a touch device (not a pen or mouse). |
isMouseEvent | Returns true if the event was generated using a mouse (not a pen or touch device). |
isLeftMouseButton | Returns true if the left mouse button is pressed for the given event. |
isMiddleMouseButton | Returns true if the middle mouse button is pressed for the given event. |
isRightMouseButton | Returns true if the right mouse button was pressed. |
isPopupTrigger | Returns true if the event is a popup trigger. |
isShiftDown | Returns true if the shift key is pressed for the given event. |
isAltDown | Returns true if the alt key is pressed for the given event. |
isControlDown | Returns true if the control key is pressed for the given event. |
isMetaDown | Returns true if the meta key is pressed for the given event. |
getMainEvent | Returns the touch or mouse event that contains the mouse coordinates. |
getClientX | Returns true if the meta key is pressed for the given event. |
getClientY | Returns true if the meta key is pressed for the given event. |
consume | Consumes the given event. |
Variables | |
LABEL_HANDLE | Index for the label handle in an mxMouseEvent. |
ROTATION_HANDLE | Index for the rotation handle in an mxMouseEvent. |
CUSTOM_HANDLE | Start index for the custom handles in an mxMouseEvent. |
VIRTUAL_HANDLE | Start index for the virtual handles in an mxMouseEvent. |
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. |
FIRE_MOUSE_EVENT | Specifies the event name for fireMouseEvent. |
GESTURE | Specifies the event name for gesture. |
TAP_AND_HOLD | Specifies the event name for tapAndHold. |
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. |
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. |
EXECUTED | Specifies the event name for executed. |
BEGIN_UPDATE | Specifies the event name for beginUpdate. |
START_EDIT | Specifies the event name for startEdit. |
END_UPDATE | Specifies the event name for endUpdate. |
END_EDIT | Specifies the event name for endEdit. |
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. |
REMOVE | Specifies the event name for remove. |
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. |
EDITING_STARTED | Specifies the event name for editingStarted. |
EDITING_STOPPED | Specifies the event name for editingStopped. |
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. |
DOUBLE_CLICK | Specifies the event name for doubleClick. |
START | Specifies the event name for start. |
RESET | Specifies the event name for reset. |
PINCH_THRESHOLD | Threshold for pinch gestures to fire a mouse wheel event. |
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.
addGestureListeners: function( node, startListener, moveListener, endListener )
Adds the given listeners for touch, mouse and/or pointer events. If mxClient.IS_POINTER is true then pointer events will be registered, else the respective mouse events will be registered. If mxClient.IS_POINTER is false and mxClient.IS_TOUCH is true then the respective touch events will be registered as well as the mouse events.
removeGestureListeners: function( node, startListener, moveListener, endListener )
Removes the given listeners from mousedown, mousemove, mouseup and the respective touch events if mxClient.IS_TOUCH is true.
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.
isConsumed: function( evt )
Returns true if the event has been consumed using consume.
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. Note that this returns true in Firefox for control+left-click on the Mac.
isMiddleMouseButton: function( evt )
Returns true if the middle 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: 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.
VIRTUAL_HANDLE: -100000
Start index for the virtual handles in an mxMouseEvent. This should be a negative value and is the start index which is decremented for each virtual handle. Default is -100000. This assumes that there are no more than VIRTUAL_HANDLE - CUSTOM_HANDLE custom handles.
Binds the function to the specified event on the given element.
addListener: function()
Removes the specified listener from the given element.
removeListener: function()
Removes all listeners from the given element.
removeAllListeners: function( element )
Adds the given listeners for touch, mouse and/or pointer events.
addGestureListeners: function( node, startListener, moveListener, endListener )
Removes the given listeners from mousedown, mousemove, mouseup and the respective touch events if mxClient.IS_TOUCH is true.
removeGestureListeners: function( node, startListener, moveListener, endListener )
True if this device supports touchstart/-move/-end events (Apple iOS, Android, Chromebook and Chrome Browser on touch-enabled devices).
IS_TOUCH: 'ontouchstart' in document.documentElement
Redirects the mouse events from the given DOM node to the graph dispatch loop using the event and given state as event arguments.
redirectMouseEvents: function( node, graph, state, down, move, up, dblClick )
Removes the known listeners from the given DOM node and its descendants.
release: function( element )
Disables the context menu for the given element.
disableContextMenu: function( element )
Returns the event’s target or srcElement depending on the browser.
getSource: function( evt )
Returns true if the event has been consumed using consume.
isConsumed: function( evt )
Consumes the given event.
consume: function( evt, preventDefault, stopPropagation )
Returns true if the event was generated using a touch device (not a pen or mouse).
isTouchEvent: function( evt )
Returns true if the event was generated using a pen (not a touch device or mouse).
isPenEvent: function( evt )
Returns true if the event was generated using a touch device (not a pen or mouse).
isMultiTouchEvent: function( evt )
Returns true if the event was generated using a mouse (not a pen or touch device).
isMouseEvent: function( evt )
Returns true if the left mouse button is pressed for the given event.
isLeftMouseButton: function( evt )
Returns true if the middle mouse button is pressed for the given event.
isMiddleMouseButton: function( evt )
Returns true if the right mouse button was pressed.
isRightMouseButton: function( evt )
Returns true if the event is a popup trigger.
isPopupTrigger: function( evt )
Returns true if the shift key is pressed for the given event.
isShiftDown: function( evt )
Returns true if the alt key is pressed for the given event.
isAltDown: function( evt )
Returns true if the control key is pressed for the given event.
isControlDown: function( evt )
Returns true if the meta key is pressed for the given event.
isMetaDown: function( evt )
Returns the touch or mouse event that contains the mouse coordinates.
getMainEvent: function( e )
Returns true if the meta key is pressed for the given event.
getClientX: function( e )
Returns true if the meta key is pressed for the given event.
getClientY: function( e )
Index for the label handle in an mxMouseEvent.
LABEL_HANDLE: -1
Index for the rotation handle in an mxMouseEvent.
ROTATION_HANDLE: -2
Start index for the custom handles in an mxMouseEvent.
CUSTOM_HANDLE: -100
Start index for the virtual handles in an mxMouseEvent.
VIRTUAL_HANDLE: -100000
Specifies the event name for mouseDown.
MOUSE_DOWN: 'mouseDown'
Specifies the event name for mouseMove.
MOUSE_MOVE: 'mouseMove'
Specifies the event name for mouseUp.
MOUSE_UP: 'mouseUp'
Specifies the event name for activate.
ACTIVATE: 'activate'
Specifies the event name for resizeStart.
RESIZE_START: 'resizeStart'
Specifies the event name for resize.
RESIZE: 'resize'
Specifies the event name for resizeEnd.
RESIZE_END: 'resizeEnd'
Specifies the event name for moveStart.
MOVE_START: 'moveStart'
Specifies the event name for move.
MOVE: 'move'
Specifies the event name for moveEnd.
MOVE_END: 'moveEnd'
Specifies the event name for panStart.
PAN_START: 'panStart'
Specifies the event name for pan.
PAN: 'pan'
Specifies the event name for panEnd.
PAN_END: 'panEnd'
Specifies the event name for minimize.
MINIMIZE: 'minimize'
Specifies the event name for normalize.
NORMALIZE: 'normalize'
Specifies the event name for maximize.
MAXIMIZE: 'maximize'
Specifies the event name for hide.
HIDE: 'hide'
Specifies the event name for show.
SHOW: 'show'
Specifies the event name for close.
CLOSE: 'close'
Specifies the event name for destroy.
DESTROY: 'destroy'
Specifies the event name for refresh.
REFRESH: 'refresh'
Specifies the event name for size.
SIZE: 'size'
Specifies the event name for select.
SELECT: 'select'
Specifies the event name for fired.
FIRED: 'fired'
Specifies the event name for fireMouseEvent.
FIRE_MOUSE_EVENT: 'fireMouseEvent'
Specifies the event name for gesture.
GESTURE: 'gesture'
Specifies the event name for tapAndHold.
TAP_AND_HOLD: 'tapAndHold'
Specifies the event name for get.
GET: 'get'
Specifies the event name for receive.
RECEIVE: 'receive'
Specifies the event name for connect.
CONNECT: 'connect'
Specifies the event name for disconnect.
DISCONNECT: 'disconnect'
Specifies the event name for suspend.
SUSPEND: 'suspend'
Specifies the event name for suspend.
RESUME: 'resume'
Specifies the event name for mark.
MARK: 'mark'
Specifies the event name for root.
ROOT: 'root'
Specifies the event name for post.
POST: 'post'
Specifies the event name for open.
OPEN: 'open'
Specifies the event name for open.
SAVE: 'save'
Specifies the event name for beforeAddVertex.
BEFORE_ADD_VERTEX: 'beforeAddVertex'
Specifies the event name for addVertex.
ADD_VERTEX: 'addVertex'
Specifies the event name for afterAddVertex.
AFTER_ADD_VERTEX: 'afterAddVertex'
Specifies the event name for done.
DONE: 'done'
Specifies the event name for execute.
EXECUTE: 'execute'
Specifies the event name for executed.
EXECUTED: 'executed'
Specifies the event name for beginUpdate.
BEGIN_UPDATE: 'beginUpdate'
Specifies the event name for startEdit.
START_EDIT: 'startEdit'
Specifies the event name for endUpdate.
END_UPDATE: 'endUpdate'
Specifies the event name for endEdit.
END_EDIT: 'endEdit'
Specifies the event name for beforeUndo.
BEFORE_UNDO: 'beforeUndo'
Specifies the event name for undo.
UNDO: 'undo'
Specifies the event name for redo.
REDO: 'redo'
Specifies the event name for change.
CHANGE: 'change'
Specifies the event name for notify.
NOTIFY: 'notify'
Specifies the event name for layoutCells.
LAYOUT_CELLS: 'layoutCells'
Specifies the event name for click.
CLICK: 'click'
Specifies the event name for scale.
SCALE: 'scale'
Specifies the event name for translate.
TRANSLATE: 'translate'
Specifies the event name for scaleAndTranslate.
SCALE_AND_TRANSLATE: 'scaleAndTranslate'
Specifies the event name for up.
UP: 'up'
Specifies the event name for down.
DOWN: 'down'
Specifies the event name for add.
ADD: 'add'
Specifies the event name for remove.
REMOVE: 'remove'
Specifies the event name for clear.
CLEAR: 'clear'
Specifies the event name for addCells.
ADD_CELLS: 'addCells'
Specifies the event name for cellsAdded.
CELLS_ADDED: 'cellsAdded'
Specifies the event name for moveCells.
MOVE_CELLS: 'moveCells'
Specifies the event name for cellsMoved.
CELLS_MOVED: 'cellsMoved'
Specifies the event name for resizeCells.
RESIZE_CELLS: 'resizeCells'
Specifies the event name for cellsResized.
CELLS_RESIZED: 'cellsResized'
Specifies the event name for toggleCells.
TOGGLE_CELLS: 'toggleCells'
Specifies the event name for cellsToggled.
CELLS_TOGGLED: 'cellsToggled'
Specifies the event name for orderCells.
ORDER_CELLS: 'orderCells'
Specifies the event name for cellsOrdered.
CELLS_ORDERED: 'cellsOrdered'
Specifies the event name for removeCells.
REMOVE_CELLS: 'removeCells'
Specifies the event name for cellsRemoved.
CELLS_REMOVED: 'cellsRemoved'
Specifies the event name for groupCells.
GROUP_CELLS: 'groupCells'
Specifies the event name for ungroupCells.
UNGROUP_CELLS: 'ungroupCells'
Specifies the event name for removeCellsFromParent.
REMOVE_CELLS_FROM_PARENT: 'removeCellsFromParent'
Specifies the event name for foldCells.
FOLD_CELLS: 'foldCells'
Specifies the event name for cellsFolded.
CELLS_FOLDED: 'cellsFolded'
Specifies the event name for alignCells.
ALIGN_CELLS: 'alignCells'
Specifies the event name for labelChanged.
LABEL_CHANGED: 'labelChanged'
Specifies the event name for connectCell.
CONNECT_CELL: 'connectCell'
Specifies the event name for cellConnected.
CELL_CONNECTED: 'cellConnected'
Specifies the event name for splitEdge.
SPLIT_EDGE: 'splitEdge'
Specifies the event name for flipEdge.
FLIP_EDGE: 'flipEdge'
Specifies the event name for startEditing.
START_EDITING: 'startEditing'
Specifies the event name for editingStarted.
EDITING_STARTED: 'editingStarted'
Specifies the event name for editingStopped.
EDITING_STOPPED: 'editingStopped'
Specifies the event name for addOverlay.
ADD_OVERLAY: 'addOverlay'
Specifies the event name for removeOverlay.
REMOVE_OVERLAY: 'removeOverlay'
Specifies the event name for updateCellSize.
UPDATE_CELL_SIZE: 'updateCellSize'
Specifies the event name for escape.
ESCAPE: 'escape'
Specifies the event name for doubleClick.
DOUBLE_CLICK: 'doubleClick'
Specifies the event name for start.
START: 'start'
Specifies the event name for reset.
RESET: 'reset'
Threshold for pinch gestures to fire a mouse wheel event.
PINCH_THRESHOLD: 10
Returns a wrapper function that locks the execution scope of the given function to the specified scope.
bind: function( scope, funct )
True if this device supports Microsoft pointer events (always false on Macs).
IS_POINTER: window.PointerEvent !
Holds the state of the mouse button.
mxGraph.prototype.isMouseDown