Class SelectionHandler

Graph event handler that handles selection. Individual cells are handled separately using VertexHandler or one of the edge handlers. These handlers are created using Graph#createHandler in GraphSelectionModel#cellAdded.

To avoid the container to scroll a moved cell into view, set scrollOnMove to false.

Implements

Constructors

Properties

allCells: Dictionary<Cell, CellState> = ...
allowLivePreview: boolean = Client.IS_SVG

Variable allowLivePreview

If live preview is allowed on this system. Default is true for systems with SVG support.

bounds: null | Rectangle = null
cell: null | Cell = null
cellCount: number = 0
cells: null | Cell[] = null
cellWasClicked: boolean = false
cloneEnabled: boolean = true

Specifies if cloning by control-drag is enabled. Default is true.

cloning: boolean = false
connectOnDrop: boolean = false

Specifies if drop events are interpreted as new connections if no other drop action is defined. Default is false.

currentDx: number = 0

Stores the x-coordinate of the current mouse move.

currentDy: number = 0

Stores the y-coordinate of the current mouse move.

delayedSelection: boolean = false
enabled: boolean = true

Specifies if events are handled. Default is true.

escapeHandler: ((sender: EventSource, evt: EventObject) => void)
first: null | Point = null
graph: Graph

Reference to the enclosing Graph.

guide: null | Guide = null

Holds the Guide instance that is used for alignment.

guidesEnabled: boolean = false

Specifies if other cells should be used for snapping the right, center or left side of the current selection. Default is false.

handlesVisible: boolean = true

Whether the handles of the selection are currently visible.

highlight: null | CellHighlight = null
highlightEnabled: boolean = true

Specifies if drop targets under the mouse should be enabled. Default is true.

htmlPreview: boolean = false

Specifies if the graph container should be used for preview. If this is used then drop target detection relies entirely on Graph#getCellAt because the HTML preview does not "let events through". Default is false.

keyHandler: ((e: KeyboardEvent) => void)
livePreviewActive: boolean = false
livePreviewUsed: boolean = false
maxCells: number = 50

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.

maxLivePreview: number = 0

Maximum number of cells for which live preview should be used. Default is 0 which means no live preview.

minimumSize: number = 6

Specifies the minimum number of pixels for the width and height of a selection border. Default is 6.

moveEnabled: boolean = true

Specifies if moving is enabled. Default is true.

panHandler: (() => void)
pBounds: null | Rectangle = null
previewColor: string = 'black'

Specifies the color of the preview shape. Default is black.

refreshHandler: ((sender: EventSource, evt: EventObject) => void)
refreshThread: null | number = null
removeCellsFromParent: boolean = true

Specifies if cells may be moved out of their parents. Default is true.

removeEmptyParents: boolean = false

If empty parents should be removed from the model after all child cells have been moved out. Default is true.

rotationEnabled: boolean = true

Specifies if the bounding box should allow for rotation. Default is true.

scaleGrid: boolean = false

Specifies if the grid should be scaled. Default is false.

scrollOnMove: boolean = true

Specifies if the view should be scrolled so that a moved cell is visible.

true
selectEnabled: boolean = true

Specifies if selecting is enabled. Default is true.

shape: null | Shape = null

Reference to the Shape that represents the preview.

suspended: boolean = false
target: null | Cell = null
updateCursor: boolean = true

Specifies if a move cursor should be shown if the mouse is over a movable cell. Default is true.

pluginId: string = 'SelectionHandler'

Methods

  • 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 evnent on the link.

    consumeMouseEvent(evtName, me) { var source = mxEvent.getSource(me.getEvent());

    if (!mxEvent.isTouchEvent(me.getEvent()) || source.nodeName != 'A') { me.consume(); } }

    Parameters

    Returns void

  • Returns the union of the CellStates for the given array of Cells. 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: GraphView#getBounds and Graph#getBoundingBox.

    Parameters

    • cells: Cell[]

      Array of Cells whose bounding box should be returned.

    Returns null | Rectangle

  • 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.

    Parameters

    • initialCell: Cell

      that triggered this handler.

    Returns Cell[]

  • Moves the given cells by the specified amount.

    Parameters

    • cells: Cell[]
    • dx: number
    • dy: number
    • clone: boolean
    • target: null | Cell
    • evt: MouseEvent

    Returns void

  • Sets wether the handles attached to the given cells are visible.

    Parameters

    • cells: Cell[]

      Array of Cells.

    • visible: boolean

      Boolean that specifies if the handles should be visible.

    • force: boolean = false

      Forces an update of the handler regardless of the last used value.

    Returns void

  • Sets the color of the rectangle used to highlight drop targets.

    Parameters

    • color: string

      String that represents the new highlight color.

    Returns void

  • Returns true if the given cells should be removed from the parent for the specified mousereleased event.

    Parameters

    • parent: Cell
    • cells: Cell[]
    • evt: MouseEvent

    Returns boolean