Graph event handler that handles selection. Individual cells are handled separately using mxVertexHandler or one of the edge handlers. These handlers are created using mxGraph.createHandler in mxGraphSelectionModel.cellAdded.
To avoid the container to scroll a moved cell into view, set <scrollAfterMove> to false.
mxGraphHandler | Graph event handler that handles selection. |
Functions | |
mxGraphHandler | Constructs an event handler that creates handles for the selection cells. |
Variables | |
graph | Reference to the enclosing mxGraph. |
maxCells | Defines the maximum number of cells to paint subhandles for. |
enabled | Specifies if events are handled. |
highlightEnabled | Specifies if drop targets under the mouse should be enabled. |
cloneEnabled | Specifies if cloning by control-drag is enabled. |
moveEnabled | Specifies if moving is enabled. |
guidesEnabled | Specifies if other cells should be used for snapping the right, center or left side of the current selection. |
handlesVisible | Whether the handles of the selection are currently visible. |
guide | Holds the mxGuide instance that is used for alignment. |
currentDx | Stores the x-coordinate of the current mouse move. |
currentDy | Stores the y-coordinate of the current mouse move. |
updateCursor | Specifies if a move cursor should be shown if the mouse is over a movable cell. |
selectEnabled | Specifies if selecting is enabled. |
removeCellsFromParent | Specifies if cells may be moved out of their parents. |
removeEmptyParents | If empty parents should be removed from the model after all child cells have been moved out. |
connectOnDrop | Specifies if drop events are interpreted as new connections if no other drop action is defined. |
scrollOnMove | Specifies if the view should be scrolled so that a moved cell is visible. |
minimumSize | Specifies the minimum number of pixels for the width and height of a selection border. |
previewColor | Specifies the color of the preview shape. |
htmlPreview | Specifies if the graph container should be used for preview. |
shape | Reference to the mxShape that represents the preview. |
scaleGrid | Specifies if the grid should be scaled. |
rotationEnabled | Specifies if the bounding box should allow for rotation. |
maxLivePreview | Maximum number of cells for which live preview should be used. |
allowLivePreview | If live preview is allowed on this system. |
Functions | |
isEnabled | Returns enabled. |
setEnabled | Sets enabled. |
isCloneEnabled | Returns cloneEnabled. |
setCloneEnabled | Sets cloneEnabled. |
isMoveEnabled | Returns moveEnabled. |
setMoveEnabled | Sets moveEnabled. |
isSelectEnabled | Returns selectEnabled. |
setSelectEnabled | Sets selectEnabled. |
isRemoveCellsFromParent | Returns removeCellsFromParent. |
setRemoveCellsFromParent | Sets removeCellsFromParent. |
isPropagateSelectionCell | Returns true if the given cell and parent should propagate selection state to the parent. |
getInitialCellForEvent | Hook to return initial cell for the given event. |
isDelayedSelection | Returns true if the cell or one of its ancestors is selected. |
selectDelayed | Implements the delayed selection for the given mouse event. |
selectCellForEvent | Selects the given cell for the given mxMouseEvent. |
consumeMouseEvent | Consumes the given mouse event. |
mouseDown | Handles the event by selecing the given cell and creating a handle for it. |
getGuideStates | Creates an array of cell states which should be used as guides. |
getCells | Returns the cells to be modified by this handler. |
getPreviewBounds | Returns the mxRectangle used as the preview bounds for moving the given cells. |
getBoundingBox | Returns the union of the mxCellStates for the given array of mxCells. |
createPreviewShape | Creates the shape used to draw the preview for the given bounds. |
start | Starts the handling of the mouse gesture. |
addStates | Adds the states for the given cell recursively to the given dictionary. |
isCellMoving | Returns true if the given cell is currently being moved. |
useGuidesForEvent | Returns true if the guides should be used for the given mxMouseEvent. |
snap | Snaps the given vector to the grid and returns the given mxPoint instance. |
getDelta | Returns an mxPoint that represents the vector for moving the cells for the given mxMouseEvent. |
updateHint | Hook for subclassers do show details while the handler is active. |
removeHint | Hooks for subclassers to hide details when the handler gets inactive. |
roundLength | Hook for rounding the unscaled vector. |
isValidDropTarget | Returns true if the given cell is a valid drop target. |
checkPreview | Updates the preview if cloning state has changed. |
mouseMove | Handles the event by highlighting possible drop targets and updating the preview. |
updatePreview | Updates the bounds of the preview shape. |
updatePreviewShape | Updates the bounds of the preview shape. |
updateLivePreview | Updates the bounds of the preview shape. |
redrawHandles | Redraws the preview shape for the given states array. |
resetPreviewStates | Resets the given preview states array. |
suspend | Suspends the livew preview. |
resume | Suspends the livew preview. |
resetLivePreview | Resets the livew preview. |
setHandlesVisibleForCells | Sets wether the handles attached to the given cells are visible. |
setHighlightColor | Sets the color of the rectangle used to highlight drop targets. |
mouseUp | Handles the event by applying the changes to the selection cells. |
reset | Resets the state of this handler. |
shouldRemoveCellsFromParent | Returns true if the given cells should be removed from the parent for the specified mousereleased event. |
moveCells | Moves the given cells by the specified amount. |
shouldRemoveParent | Returns true if the given parent should be removed after removal of child cells. |
destroyShapes | Destroy the preview and highlight shapes. |
destroy | Destroys the handler and all its resources and DOM nodes. |
function mxGraphHandler( graph )
Constructs an event handler that creates handles for the selection cells.
graph | Reference to the enclosing mxGraph. |
mxGraphHandler.prototype.graph
Reference to the enclosing mxGraph.
mxGraphHandler.prototype.maxCells
Defines the maximum number of cells to paint subhandles for. Default is 50 for Firefox and 20 for IE. Set this to 0 if you want an unlimited number of handles to be displayed. This is only recommended if the number of cells in the graph is limited to a small number, eg. 500.
mxGraphHandler.prototype.guide
Holds the mxGuide instance that is used for alignment.
mxGraphHandler.prototype.htmlPreview
Specifies if the graph container should be used for preview. If this is used then drop target detection relies entirely on mxGraph.getCellAt because the HTML preview does not “let events through”. Default is false.
mxGraphHandler.prototype.shape
Reference to the mxShape that represents the preview.
mxGraphHandler.prototype.isEnabled = function()
Returns enabled.
mxGraphHandler.prototype.setEnabled = function( value )
Sets enabled.
mxGraphHandler.prototype.isCloneEnabled = function()
Returns cloneEnabled.
mxGraphHandler.prototype.setCloneEnabled = function( value )
Sets cloneEnabled.
value | Boolean that specifies the new clone enabled state. |
mxGraphHandler.prototype.isMoveEnabled = function()
Returns moveEnabled.
mxGraphHandler.prototype.setMoveEnabled = function( value )
Sets moveEnabled.
mxGraphHandler.prototype.isSelectEnabled = function()
Returns selectEnabled.
mxGraphHandler.prototype.setSelectEnabled = function( value )
Sets selectEnabled.
mxGraphHandler.prototype.isRemoveCellsFromParent = function()
Returns removeCellsFromParent.
mxGraphHandler.prototype.setRemoveCellsFromParent = function( value )
Sets removeCellsFromParent.
mxGraphHandler.prototype.selectCellForEvent = function( cell, me )
Selects the given cell for the given mxMouseEvent.
mxGraphHandler.prototype.consumeMouseEvent = function( evtName, me )
Consumes the given mouse event. NOTE: This may be used to enable click events for links in labels on iOS as follows as consuming the initial touchStart disables firing the subsequent click event on the link.
<code> mxGraphHandler.prototype.consumeMouseEvent = function(evtName, me) { var source = mxEvent.getSource(me.getEvent());
if (!mxEvent.isTouchEvent(me.getEvent()) || source.nodeName != ‘A’) { me.consume(); } } </code>
mxGraphHandler.prototype.getCells = function( initialCell )
Returns the cells to be modified by this handler. This implementation returns all selection cells that are movable, or the given initial cell if the given cell is not selected and movable. This handles the case of moving unselectable or unselected cells.
initialCell | mxCell that triggered this handler. |
mxGraphHandler.prototype.getPreviewBounds = function( cells )
Returns the mxRectangle used as the preview bounds for moving the given cells.
mxGraphHandler.prototype.getBoundingBox = function( cells )
Returns the union of the mxCellStates for the given array of mxCells. For vertices, this method uses the bounding box of the corresponding shape if one exists. The bounding box of the corresponding text label and all controls and overlays are ignored. See also: mxGraphView.getBounds and mxGraph.getBoundingBox.
cells | Array of mxCells whose bounding box should be returned. |
mxGraphHandler.prototype.useGuidesForEvent = function( me )
Returns true if the guides should be used for the given mxMouseEvent. This implementation returns mxGuide.isEnabledForEvent.
mxGraphHandler.prototype.getDelta = function( me )
Returns an mxPoint that represents the vector for moving the cells for the given mxMouseEvent.
mxGraphHandler.prototype.setHandlesVisibleForCells = function( cells, visible, force )
Sets wether the handles attached to the given cells are visible.
cells | Array of mxCells. |
visible | Boolean that specifies if the handles should be visible. |
force | Forces an update of the handler regardless of the last used value. |
Constructs an event handler that creates handles for the selection cells.
function mxGraphHandler( graph )
Reference to the enclosing mxGraph.
mxGraphHandler.prototype.graph
Defines the maximum number of cells to paint subhandles for.
mxGraphHandler.prototype.maxCells
Specifies if events are handled.
mxGraphHandler.prototype.enabled
Specifies if drop targets under the mouse should be enabled.
mxGraphHandler.prototype.highlightEnabled
Specifies if cloning by control-drag is enabled.
mxGraphHandler.prototype.cloneEnabled
Specifies if moving is enabled.
mxGraphHandler.prototype.moveEnabled
Specifies if other cells should be used for snapping the right, center or left side of the current selection.
mxGraphHandler.prototype.guidesEnabled
Whether the handles of the selection are currently visible.
mxGraphHandler.prototype.handlesVisible
Holds the mxGuide instance that is used for alignment.
mxGraphHandler.prototype.guide
Stores the x-coordinate of the current mouse move.
mxGraphHandler.prototype.currentDx
Stores the y-coordinate of the current mouse move.
mxGraphHandler.prototype.currentDy
Specifies if a move cursor should be shown if the mouse is over a movable cell.
mxGraphHandler.prototype.updateCursor
Specifies if selecting is enabled.
mxGraphHandler.prototype.selectEnabled
Specifies if cells may be moved out of their parents.
mxGraphHandler.prototype.removeCellsFromParent
If empty parents should be removed from the model after all child cells have been moved out.
mxGraphHandler.prototype.removeEmptyParents
Specifies if drop events are interpreted as new connections if no other drop action is defined.
mxGraphHandler.prototype.connectOnDrop
Specifies if the view should be scrolled so that a moved cell is visible.
mxGraphHandler.prototype.scrollOnMove
Specifies the minimum number of pixels for the width and height of a selection border.
mxGraphHandler.prototype.minimumSize
Specifies the color of the preview shape.
mxGraphHandler.prototype.previewColor
Specifies if the graph container should be used for preview.
mxGraphHandler.prototype.htmlPreview
Reference to the mxShape that represents the preview.
mxGraphHandler.prototype.shape
Specifies if the grid should be scaled.
mxGraphHandler.prototype.scaleGrid
Specifies if the bounding box should allow for rotation.
mxGraphHandler.prototype.rotationEnabled
Maximum number of cells for which live preview should be used.
mxGraphHandler.prototype.maxLivePreview
If live preview is allowed on this system.
mxGraphHandler.prototype.allowLivePreview
Returns enabled.
mxGraphHandler.prototype.isEnabled = function()
Sets enabled.
mxGraphHandler.prototype.setEnabled = function( value )
Returns cloneEnabled.
mxGraphHandler.prototype.isCloneEnabled = function()
Sets cloneEnabled.
mxGraphHandler.prototype.setCloneEnabled = function( value )
Returns moveEnabled.
mxGraphHandler.prototype.isMoveEnabled = function()
Sets moveEnabled.
mxGraphHandler.prototype.setMoveEnabled = function( value )
Returns selectEnabled.
mxGraphHandler.prototype.isSelectEnabled = function()
Sets selectEnabled.
mxGraphHandler.prototype.setSelectEnabled = function( value )
Returns removeCellsFromParent.
mxGraphHandler.prototype.isRemoveCellsFromParent = function()
Sets removeCellsFromParent.
mxGraphHandler.prototype.setRemoveCellsFromParent = function( value )
Returns true if the given cell and parent should propagate selection state to the parent.
mxGraphHandler.prototype.isPropagateSelectionCell = function( cell, immediate, me )
Hook to return initial cell for the given event.
mxGraphHandler.prototype.getInitialCellForEvent = function( me )
Returns true if the cell or one of its ancestors is selected.
mxGraphHandler.prototype.isDelayedSelection = function( cell, me )
Implements the delayed selection for the given mouse event.
mxGraphHandler.prototype.selectDelayed = function( me )
Selects the given cell for the given mxMouseEvent.
mxGraphHandler.prototype.selectCellForEvent = function( cell, me )
Consumes the given mouse event.
mxGraphHandler.prototype.consumeMouseEvent = function( evtName, me )
Handles the event by selecing the given cell and creating a handle for it.
mxGraphHandler.prototype.mouseDown = function( sender, me )
Creates an array of cell states which should be used as guides.
mxGraphHandler.prototype.getGuideStates = function()
Returns the cells to be modified by this handler.
mxGraphHandler.prototype.getCells = function( initialCell )
Returns the mxRectangle used as the preview bounds for moving the given cells.
mxGraphHandler.prototype.getPreviewBounds = function( cells )
Returns the union of the mxCellStates for the given array of mxCells.
mxGraphHandler.prototype.getBoundingBox = function( cells )
Creates the shape used to draw the preview for the given bounds.
mxGraphHandler.prototype.createPreviewShape = function( bounds )
Starts the handling of the mouse gesture.
mxGraphHandler.prototype.start = function( cell, x, y, cells )
Adds the states for the given cell recursively to the given dictionary.
mxGraphHandler.prototype.addStates = function( cell, dict )
Returns true if the given cell is currently being moved.
mxGraphHandler.prototype.isCellMoving = function( cell )
Returns true if the guides should be used for the given mxMouseEvent.
mxGraphHandler.prototype.useGuidesForEvent = function( me )
Snaps the given vector to the grid and returns the given mxPoint instance.
mxGraphHandler.prototype.snap = function( vector )
Returns an mxPoint that represents the vector for moving the cells for the given mxMouseEvent.
mxGraphHandler.prototype.getDelta = function( me )
Hook for subclassers do show details while the handler is active.
mxGraphHandler.prototype.updateHint = function( me )
Hooks for subclassers to hide details when the handler gets inactive.
mxGraphHandler.prototype.removeHint = function()
Hook for rounding the unscaled vector.
mxGraphHandler.prototype.roundLength = function( length )
Returns true if the given cell is a valid drop target.
mxGraphHandler.prototype.isValidDropTarget = function( target, me )
Updates the preview if cloning state has changed.
mxGraphHandler.prototype.checkPreview = function()
Handles the event by highlighting possible drop targets and updating the preview.
mxGraphHandler.prototype.mouseMove = function( sender, me )
Updates the bounds of the preview shape.
mxGraphHandler.prototype.updatePreview = function( remote )
Updates the bounds of the preview shape.
mxGraphHandler.prototype.updatePreviewShape = function()
Updates the bounds of the preview shape.
mxGraphHandler.prototype.updateLivePreview = function( dx, dy )
Redraws the preview shape for the given states array.
mxGraphHandler.prototype.redrawHandles = function( states )
Resets the given preview states array.
mxGraphHandler.prototype.resetPreviewStates = function( states )
Suspends the livew preview.
mxGraphHandler.prototype.suspend = function()
Suspends the livew preview.
mxGraphHandler.prototype.resume = function()
Resets the livew preview.
mxGraphHandler.prototype.resetLivePreview = function()
Sets wether the handles attached to the given cells are visible.
mxGraphHandler.prototype.setHandlesVisibleForCells = function( cells, visible, force )
Sets the color of the rectangle used to highlight drop targets.
mxGraphHandler.prototype.setHighlightColor = function( color )
Handles the event by applying the changes to the selection cells.
mxGraphHandler.prototype.mouseUp = function( sender, me )
Resets the state of this handler.
mxGraphHandler.prototype.reset = function()
Returns true if the given cells should be removed from the parent for the specified mousereleased event.
mxGraphHandler.prototype.shouldRemoveCellsFromParent = function( parent, cells, evt )
Moves the given cells by the specified amount.
mxGraphHandler.prototype.moveCells = function( cells, dx, dy, clone, target, evt )
Returns true if the given parent should be removed after removal of child cells.
mxGraphHandler.prototype.shouldRemoveParent = function( parent )
Destroy the preview and highlight shapes.
mxGraphHandler.prototype.destroyShapes = function()
Destroys the handler and all its resources and DOM nodes.
mxGraphHandler.prototype.destroy = function()
Creates a new handler for the given cell state.
mxGraph.prototype.createHandler = function( state )
Inner callback to add the specified mxCell to the selection.
mxGraphSelectionModel.prototype.cellAdded = function( cell )
Returns the bottom-most cell that intersects the given point (x, y) in the cell hierarchy starting at the given parent.
mxGraph.prototype.getCellAt = function( x, y, parent, vertices, edges, ignoreFn )
Returns the union of all mxCellStates for the given array of mxCells.
mxGraphView.prototype.getBounds = function( cells )
Returns the bounding box for the given array of mxCells.
mxGraph.prototype.getBoundingBox = function( cells )
Returns true if the guide should be enabled for the given native event.
mxGuide.prototype.isEnabledForEvent = function( evt )