GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • @maxgraph/core

This view

  • Original page
  • New address

GeezerVison is showing maxgraph.github.io — SelectionHandler | @maxgraph/core

  • SelectionHandler

Class SelectionHandler

Graph event handler that handles selection.

Individual cells are handled separately by SelectionCellsHandler using VertexHandler or one of the EdgeHandlers. When the SelectionCellsHandler plugin is registered in the AbstractGraph, SelectionHandler interacts with this plugin to propagate global selection events to individual cells.

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

Implements

  • GraphPlugin
  • MouseListenerSet
  • Defined in view/plugin/SelectionHandler.ts:64
Index

Constructors

constructor

Properties

allCells allowLivePreview bounds cell cellCount cells cellWasClicked cloneEnabled cloning connectOnDrop currentDx currentDy delayedSelection enabled escapeHandler first graph guide guidesEnabled handlesVisible highlight highlightEnabled htmlPreview keyHandler livePreviewActive livePreviewUsed maxCells maxLivePreview minimumSize moveEnabled panHandler pBounds previewColor refreshHandler refreshThread removeCellsFromParent removeEmptyParents rotationEnabled scaleGrid scrollOnMove selectEnabled shape suspended target updateCursor pluginId

Methods

addStates checkPreview consumeMouseEvent createGuide createPreviewShape destroyShapes getBoundingBox getCells getDelta getGuideStates getInitialCellForEvent getPreviewBounds isCellMoving isCloneEnabled isDelayedSelection isEnabled isMoveEnabled isPropagateSelectionCell isRemoveCellsFromParent isSelectEnabled isValidDropTarget mouseDown mouseMove mouseUp moveCells onDestroy redrawHandles removeHint reset resetLivePreview resetPreviewStates resume roundLength selectCellForEvent selectDelayed setCloneEnabled setEnabled setHandlesVisibleForCells setHighlightColor setMoveEnabled setRemoveCellsFromParent setSelectEnabled shouldRemoveCellsFromParent shouldRemoveParent snap start suspend updateHint updateLivePreview updatePreview updatePreviewShape useGuidesForEvent

Constructors

constructor

  • new SelectionHandler(graph: AbstractGraph): SelectionHandler

    Constructs an event handler that creates handles for the selection cells.

    Parameters

    • graph: AbstractGraph

      Reference to the enclosing AbstractGraph.

    Returns SelectionHandler

    • Defined in view/plugin/SelectionHandler.ts:72

Properties

allCells

allCells: Map<Cell, CellState> = ...
  • Defined in view/plugin/SelectionHandler.ts:332

allowLivePreview

allowLivePreview: boolean = Client.IS_SVG

If live preview is allowed on this system.

Default

true for systems with SVG support.
  • Defined in view/plugin/SelectionHandler.ts:322

bounds

bounds: Rectangle | null = null
  • Defined in view/plugin/SelectionHandler.ts:330

cell

cell: Cell | null = null
  • Defined in view/plugin/SelectionHandler.ts:324

cellCount

cellCount: number = 0
  • Defined in view/plugin/SelectionHandler.ts:336

cells

cells: Cell[] | null = null
  • Defined in view/plugin/SelectionHandler.ts:329

cellWasClicked

cellWasClicked: boolean = false
  • Defined in view/plugin/SelectionHandler.ts:334

cloneEnabled

cloneEnabled: boolean = true

Specifies if cloning by control-drag is enabled.

Default

true
  • Defined in view/plugin/SelectionHandler.ts:202

cloning

cloning: boolean = false
  • Defined in view/plugin/SelectionHandler.ts:335

connectOnDrop

connectOnDrop: boolean = false

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

Default

false
  • Defined in view/plugin/SelectionHandler.ts:265

currentDx

currentDx: number = 0

Stores the x-coordinate of the current mouse move.

  • Defined in view/plugin/SelectionHandler.ts:230

currentDy

currentDy: number = 0

Stores the y-coordinate of the current mouse move.

  • Defined in view/plugin/SelectionHandler.ts:235

delayedSelection

delayedSelection: boolean = false
  • Defined in view/plugin/SelectionHandler.ts:326

enabled

enabled: boolean = true

Specifies if events are handled.

Default

true
  • Defined in view/plugin/SelectionHandler.ts:190

escapeHandler

escapeHandler: (sender: EventSource, evt: EventObject) => void
  • Defined in view/plugin/SelectionHandler.ts:172

first

first: Point | null = null
  • Defined in view/plugin/SelectionHandler.ts:328

graph

graph: AbstractGraph

Reference to the enclosing AbstractGraph.

  • Defined in view/plugin/SelectionHandler.ts:169

guide

guide: Guide | null = null

Holds the Guide instance that is used for alignment.

  • Defined in view/plugin/SelectionHandler.ts:225

guidesEnabled

guidesEnabled: boolean = false

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

Default

false
  • Defined in view/plugin/SelectionHandler.ts:214

handlesVisible

handlesVisible: boolean = true

Whether the handles of the selection are currently visible.

Default

true
  • Defined in view/plugin/SelectionHandler.ts:220

highlight

highlight: CellHighlight | null = null
  • Defined in view/plugin/SelectionHandler.ts:344

highlightEnabled

highlightEnabled: boolean = true

Specifies if drop targets under the mouse should be enabled.

Default

true
  • Defined in view/plugin/SelectionHandler.ts:196

htmlPreview

htmlPreview: boolean = false

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

Default

false
  • Defined in view/plugin/SelectionHandler.ts:291

keyHandler

keyHandler: (e: KeyboardEvent) => void
  • Defined in view/plugin/SelectionHandler.ts:174

livePreviewActive

livePreviewActive: boolean = false
  • Defined in view/plugin/SelectionHandler.ts:341

livePreviewUsed

livePreviewUsed: boolean = false
  • Defined in view/plugin/SelectionHandler.ts:342

maxCells

maxCells: number = 50

Defines the maximum number of cells to paint sub-handles for.

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, e.g. 500.

Default

50
  • Defined in view/plugin/SelectionHandler.ts:184

maxLivePreview

maxLivePreview: number = 0

Maximum number of cells for which live preview should be used.

0 means no live preview.

Default

0
  • Defined in view/plugin/SelectionHandler.ts:316

minimumSize

minimumSize: number = 6

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

Default

6
  • Defined in view/plugin/SelectionHandler.ts:277

moveEnabled

moveEnabled: boolean = true

Specifies if moving is enabled.

Default

true
  • Defined in view/plugin/SelectionHandler.ts:208

panHandler

panHandler: () => void
  • Defined in view/plugin/SelectionHandler.ts:171

pBounds

pBounds: Rectangle | null = null
  • Defined in view/plugin/SelectionHandler.ts:331

previewColor

previewColor: string = 'black'

Specifies the color of the preview shape.

Default

black
  • Defined in view/plugin/SelectionHandler.ts:283

refreshHandler

refreshHandler: (sender: EventSource, evt: EventObject) => void
  • Defined in view/plugin/SelectionHandler.ts:173

refreshThread

refreshThread: number | null = null
  • Defined in view/plugin/SelectionHandler.ts:175

removeCellsFromParent

removeCellsFromParent: boolean = true

Specifies if cells may be moved out of their parents.

Default

true
  • Defined in view/plugin/SelectionHandler.ts:253

removeEmptyParents

removeEmptyParents: boolean = false

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

Default

false
  • Defined in view/plugin/SelectionHandler.ts:259

rotationEnabled

rotationEnabled: boolean = true

Specifies if the bounding box should allow for rotation.

Default

true
  • Defined in view/plugin/SelectionHandler.ts:308

scaleGrid

scaleGrid: boolean = false

Specifies if the grid should be scaled.

Default

false
  • Defined in view/plugin/SelectionHandler.ts:302

scrollOnMove

scrollOnMove: boolean = true

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

Default

true
  • Defined in view/plugin/SelectionHandler.ts:271

selectEnabled

selectEnabled: boolean = true

Specifies if selecting is enabled.

Default

true
  • Defined in view/plugin/SelectionHandler.ts:247

shape

shape: Shape | null = null

Reference to the Shape that represents the preview.

  • Defined in view/plugin/SelectionHandler.ts:296

suspended

suspended: boolean = false
  • Defined in view/plugin/SelectionHandler.ts:340

target

target: Cell | null = null
  • Defined in view/plugin/SelectionHandler.ts:338

updateCursor

updateCursor: boolean = true

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

Default

true
  • Defined in view/plugin/SelectionHandler.ts:241

Static ReadonlypluginId

pluginId: "SelectionHandler" = 'SelectionHandler'
  • Defined in view/plugin/SelectionHandler.ts:65

Methods

addStates

  • addStates(cell: Cell, cellStates: Map<Cell, CellState>): number

    Adds the states for the given cell recursively to the given Map.

    Parameters

    • cell: Cell
    • cellStates: Map<Cell, CellState>

    Returns number

    • Defined in view/plugin/SelectionHandler.ts:796

checkPreview

  • checkPreview(): void

    Updates the preview if cloning state has changed.

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:889

consumeMouseEvent

  • consumeMouseEvent(_evtName: string, me: InternalMouseEvent): void

    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.

    consumeMouseEvent(evtName, me) {
    const source = eventUtils.getSource(me.getEvent());

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

    Parameters

    • _evtName: string
    • me: InternalMouseEvent

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:552

createGuide

  • createGuide(): Guide

    Hook to override the creation of the Guide instance used by the class.

    Returns Guide

    • Defined in view/plugin/SelectionHandler.ts:737

createPreviewShape

  • createPreviewShape(bounds: Rectangle): RectangleShape

    Creates the shape used to draw the preview for the given bounds.

    Parameters

    • bounds: Rectangle

    Returns RectangleShape

    • Defined in view/plugin/SelectionHandler.ts:709

destroyShapes

  • destroyShapes(): void

    Destroy the preview and highlight shapes.

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:1612

getBoundingBox

  • getBoundingBox(cells: Cell[]): Rectangle | null

    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 AbstractGraph.getBoundingBox.

    Parameters

    • cells: Cell[]

      Array of Cells whose bounding box should be returned.

    Returns Rectangle | null

    • Defined in view/plugin/SelectionHandler.ts:677

getCells

  • getCells(initialCell: Cell): Cell[]

    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

      Cell that triggered this handler.

    Returns Cell[]

    • Defined in view/plugin/SelectionHandler.ts:629

getDelta

  • getDelta(me: InternalMouseEvent): Point

    Returns an Point that represents the vector for moving the cells for the given MouseEvent.

    Parameters

    • me: InternalMouseEvent

    Returns Point

    • Defined in view/plugin/SelectionHandler.ts:847

getGuideStates

  • getGuideStates(): CellState[]

    Creates an array of cell states which should be used as guides.

    Returns CellState[]

    • Defined in view/plugin/SelectionHandler.ts:607

getInitialCellForEvent

  • getInitialCellForEvent(me: InternalMouseEvent): Cell | null

    Hook to return initial cell for the given event.

    Parameters

    • me: InternalMouseEvent

    Returns Cell | null

    • Defined in view/plugin/SelectionHandler.ts:445

getPreviewBounds

  • getPreviewBounds(cells: Cell[]): Rectangle | null

    Returns the Rectangle used as the preview bounds for moving the given cells.

    Parameters

    • cells: Cell[]

    Returns Rectangle | null

    • Defined in view/plugin/SelectionHandler.ts:639

isCellMoving

  • isCellMoving(cell: Cell): boolean

    Returns true if the given cell is currently being moved.

    Parameters

    • cell: Cell

    Returns boolean

    • Defined in view/plugin/SelectionHandler.ts:819

isCloneEnabled

  • isCloneEnabled(): boolean

    Returns cloneEnabled.

    Returns boolean

    • Defined in view/plugin/SelectionHandler.ts:363

isDelayedSelection

  • isDelayedSelection(cell: Cell, me: InternalMouseEvent): boolean

    Hook to return true for delayed selections.

    Parameters

    • cell: Cell
    • me: InternalMouseEvent

    Returns boolean

    • Defined in view/plugin/SelectionHandler.ts:474

isEnabled

  • isEnabled(): boolean

    Returns enabled.

    Returns boolean

    • Defined in view/plugin/SelectionHandler.ts:349

isMoveEnabled

  • isMoveEnabled(): boolean

    Returns moveEnabled.

    Returns boolean

    • Defined in view/plugin/SelectionHandler.ts:379

isPropagateSelectionCell

  • isPropagateSelectionCell(
        cell: Cell,
        immediate: boolean,
        me: InternalMouseEvent,
    ): boolean

    Returns true if the given cell and parent should propagate selection state to the parent.

    Parameters

    • cell: Cell
    • immediate: boolean
    • me: InternalMouseEvent

    Returns boolean

    • Defined in view/plugin/SelectionHandler.ts:421

isRemoveCellsFromParent

  • isRemoveCellsFromParent(): boolean

    Returns removeCellsFromParent.

    Returns boolean

    • Defined in view/plugin/SelectionHandler.ts:407

isSelectEnabled

  • isSelectEnabled(): boolean

    Returns selectEnabled.

    Returns boolean

    • Defined in view/plugin/SelectionHandler.ts:393

isValidDropTarget

  • isValidDropTarget(target: Cell, me: InternalMouseEvent): boolean

    Returns true if the given cell is a valid drop target.

    Parameters

    • target: Cell
    • me: InternalMouseEvent

    Returns boolean

    • Defined in view/plugin/SelectionHandler.ts:882

mouseDown

  • mouseDown(_sender: EventSource, me: InternalMouseEvent): void

    Handles the event by selecting the given cell and creating a handle for it. By consuming the event all subsequent events of the gesture are redirected to this handler.

    Parameters

    • _sender: EventSource
    • me: InternalMouseEvent

    Returns void

    Implementation of MouseListenerSet.mouseDown

    • Defined in view/plugin/SelectionHandler.ts:560

mouseMove

  • mouseMove(_sender: EventSource, me: InternalMouseEvent): void

    Handles the event by highlighting possible drop targets and updating the preview.

    Parameters

    • _sender: EventSource
    • me: InternalMouseEvent

    Returns void

    Implementation of MouseListenerSet.mouseMove

    • Defined in view/plugin/SelectionHandler.ts:910

mouseUp

  • mouseUp(_sender: EventSource, me: InternalMouseEvent): void

    Handles the event by applying the changes to the selection cells.

    Parameters

    • _sender: EventSource
    • me: InternalMouseEvent

    Returns void

    Implementation of MouseListenerSet.mouseUp

    • Defined in view/plugin/SelectionHandler.ts:1389

moveCells

  • moveCells(
        cells: Cell[],
        dx: number,
        dy: number,
        clone: boolean,
        target: Cell | null,
        evt: MouseEvent,
    ): void

    Moves the given cells by the specified amount.

    Parameters

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

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:1521

onDestroy

  • onDestroy(): void

    Destroys the handler and all its resources and DOM nodes.

    Returns void

    Implementation of GraphPlugin.onDestroy

    • Defined in view/plugin/SelectionHandler.ts:1634

redrawHandles

  • redrawHandles(states: CellState[][]): void

    Redraws the preview shape for the given states array.

    Parameters

    • states: CellState[][]

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:1247

removeHint

  • removeHint(): void

    Hooks for subclassers to hide details when the handler gets inactive.

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:868

reset

  • reset(): void

    Resets the state of this handler.

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:1462

resetLivePreview

  • resetLivePreview(): void

    Resets the live preview.

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:1310

resetPreviewStates

  • resetPreviewStates(states: CellState[][]): void

    Resets the given preview states array.

    Parameters

    • states: CellState[][]

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:1259

resume

  • resume(): void

    Resumes the live preview.

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:1289

roundLength

  • roundLength(length: number): number

    Hook for rounding the unscaled vector. This uses Math.round and keep only 2 digits.

    Parameters

    • length: number

    Returns number

    • Defined in view/plugin/SelectionHandler.ts:875

selectCellForEvent

  • selectCellForEvent(cell: Cell, me: InternalMouseEvent): Cell

    Selects the given cell for the given MouseEvent.

    Parameters

    • cell: Cell
    • me: InternalMouseEvent

    Returns Cell

    • Defined in view/plugin/SelectionHandler.ts:510

selectDelayed

  • selectDelayed(me: InternalMouseEvent): void

    Implements the delayed selection for the given mouse event.

    Parameters

    • me: InternalMouseEvent

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:495

setCloneEnabled

  • setCloneEnabled(value: boolean): void

    Sets cloneEnabled.

    Parameters

    • value: boolean

      Boolean that specifies the new clone enabled state.

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:372

setEnabled

  • setEnabled(value: boolean): void

    Sets enabled.

    Parameters

    • value: boolean

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:356

setHandlesVisibleForCells

  • setHandlesVisibleForCells(
        cells: Cell[],
        visible: boolean,
        force?: boolean,
    ): void

    Sets whether 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

    • Defined in view/plugin/SelectionHandler.ts:1357

setHighlightColor

  • setHighlightColor(color: string): void

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

    Parameters

    • color: string

      String that represents the new highlight color.

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:1380

setMoveEnabled

  • setMoveEnabled(value: boolean): void

    Sets moveEnabled.

    Parameters

    • value: boolean

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:386

setRemoveCellsFromParent

  • setRemoveCellsFromParent(value: boolean): void

    Sets removeCellsFromParent.

    Parameters

    • value: boolean

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:414

setSelectEnabled

  • setSelectEnabled(value: boolean): void

    Sets selectEnabled.

    Parameters

    • value: boolean

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:400

shouldRemoveCellsFromParent

  • shouldRemoveCellsFromParent(
        parent: Cell,
        cells: Cell[],
        evt: MouseEvent,
    ): boolean

    Returns true if the given cells should be removed from the parent for the specified "mouse released" event.

    Parameters

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

    Returns boolean

    • Defined in view/plugin/SelectionHandler.ts:1495

shouldRemoveParent

  • shouldRemoveParent(parent: Cell): boolean

    Returns true if the given parent should be removed after removal of child cells.

    Parameters

    • parent: Cell

    Returns boolean

    • Defined in view/plugin/SelectionHandler.ts:1597

snap

  • snap(vector: Point): Point

    Snaps the given vector to the grid and returns the given Point instance.

    Parameters

    • vector: Point

    Returns Point

    • Defined in view/plugin/SelectionHandler.ts:837

start

  • start(cell: Cell, x: number, y: number, cells?: Cell[]): void

    Starts the handling of the mouse gesture.

    Parameters

    • cell: Cell
    • x: number
    • y: number
    • Optionalcells: Cell[]

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:744

suspend

  • suspend(): void

    Suspends the live preview.

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:1268

updateHint

  • updateHint(me?: InternalMouseEvent): void

    Hook for subclassers do show details while the handler is active.

    Parameters

    • Optionalme: InternalMouseEvent

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:861

updateLivePreview

  • updateLivePreview(dx: number, dy: number): void

    Updates the bounds of the preview shape.

    Parameters

    • dx: number
    • dy: number

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:1091

updatePreview

  • updatePreview(remote?: boolean): void

    Updates the bounds of the preview shape.

    Parameters

    • remote: boolean = false

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:1059

updatePreviewShape

  • updatePreviewShape(): void

    Updates the bounds of the preview shape.

    Returns void

    • Defined in view/plugin/SelectionHandler.ts:1076

useGuidesForEvent

  • useGuidesForEvent(me: InternalMouseEvent): boolean

    Returns true if the guides should be used for the given MouseEvent. This implementation returns Guide#isEnabledForEvent.

    Parameters

    • me: InternalMouseEvent

    Returns boolean

    • Defined in view/plugin/SelectionHandler.ts:827

Settings

Member Visibility
  • Protected
  • Inherited
Theme

On This Page

Constructors
constructor
Properties
allCellsallowLivePreviewboundscellcellCountcellscellWasClickedcloneEnabledcloningconnectOnDropcurrentDxcurrentDydelayedSelectionenabledescapeHandlerfirstgraphguideguidesEnabledhandlesVisiblehighlighthighlightEnabledhtmlPreviewkeyHandlerlivePreviewActivelivePreviewUsedmaxCellsmaxLivePreviewminimumSizemoveEnabledpanHandlerpBoundspreviewColorrefreshHandlerrefreshThreadremoveCellsFromParentremoveEmptyParentsrotationEnabledscaleGridscrollOnMoveselectEnabledshapesuspendedtargetupdateCursorpluginId
Methods
addStatescheckPreviewconsumeMouseEventcreateGuidecreatePreviewShapedestroyShapesgetBoundingBoxgetCellsgetDeltagetGuideStatesgetInitialCellForEventgetPreviewBoundsisCellMovingisCloneEnabledisDelayedSelectionisEnabledisMoveEnabledisPropagateSelectionCellisRemoveCellsFromParentisSelectEnabledisValidDropTargetmouseDownmouseMovemouseUpmoveCellsonDestroyredrawHandlesremoveHintresetresetLivePreviewresetPreviewStatesresumeroundLengthselectCellForEventselectDelayedsetCloneEnabledsetEnabledsetHandlesVisibleForCellssetHighlightColorsetMoveEnabledsetRemoveCellsFromParentsetSelectEnabledshouldRemoveCellsFromParentshouldRemoveParentsnapstartsuspendupdateHintupdateLivePreviewupdatePreviewupdatePreviewShapeuseGuidesForEvent
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.