GeezerVison is showing maxgraph.github.io — SelectionHandler | @maxgraph/core
Constructors
constructor
-
Constructs an event handler that creates handles for the selection cells.
Returns SelectionHandler
Properties
allowLivePreview
allowLivePreview: boolean = Client.IS_SVG
If live preview is allowed on this system.
Defaulttrue for systems with SVG support.
cellCount
cellCount: number = 0
cells
cells: Cell[] | null = null
cellWasClicked
cellWasClicked: boolean = false
cloneEnabled
cloneEnabled: boolean = true
Specifies if cloning by control-drag is enabled.
cloning
cloning: boolean = false
connectOnDrop
connectOnDrop: boolean = false
Specifies if drop events are interpreted as new connections if no other drop action is defined.
currentDx
currentDx: number = 0
Stores the x-coordinate of the current mouse move.
currentDy
currentDy: number = 0
Stores the y-coordinate of the current mouse move.
delayedSelection
delayedSelection: boolean = false
enabled
enabled: boolean = true
Specifies if events are handled.
first
first: Point | null = null
guide
guide: Guide | null = null
Holds the Guide instance that is used for alignment.
guidesEnabled
guidesEnabled: boolean = false
Specifies if other cells should be used for snapping the right, center or left side of the current selection.
handlesVisible
handlesVisible: boolean = true
Whether the handles of the selection are currently visible.
highlightEnabled
highlightEnabled: boolean = true
Specifies if drop targets under the mouse should be enabled.
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".
keyHandler
keyHandler: (e: KeyboardEvent) => void
livePreviewActive
livePreviewActive: boolean = false
livePreviewUsed
livePreviewUsed: boolean = false
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.
maxLivePreview
maxLivePreview: number = 0
Maximum number of cells for which live preview should be used.
0 means no live preview.
minimumSize
minimumSize: number = 6
Specifies the minimum number of pixels for the width and height of a selection border.
moveEnabled
moveEnabled: boolean = true
Specifies if moving is enabled.
panHandler
panHandler: () => void
previewColor
previewColor: string = 'black'
Specifies the color of the preview shape.
refreshThread
refreshThread: number | null = null
removeCellsFromParent
removeCellsFromParent: boolean = true
Specifies if cells may be moved out of their parents.
removeEmptyParents
removeEmptyParents: boolean = false
If empty parents should be removed from the model after all child cells have been moved out.
rotationEnabled
rotationEnabled: boolean = true
Specifies if the bounding box should allow for rotation.
scaleGrid
scaleGrid: boolean = false
Specifies if the grid should be scaled.
scrollOnMove
scrollOnMove: boolean = true
Specifies if the view should be scrolled so that a moved cell is visible.
selectEnabled
selectEnabled: boolean = true
Specifies if selecting is enabled.
shape
shape: Shape | null = null
Reference to the Shape that represents the preview.
suspended
suspended: boolean = false
target
target: Cell | null = null
updateCursor
updateCursor: boolean = true
Specifies if a move cursor should be shown if the mouse is over a movable cell.
Static ReadonlypluginId
pluginId: "SelectionHandler" = 'SelectionHandler'
Methods
addStates
-
Adds the states for the given cell recursively to the given Map.
Returns number
checkPreview
-
Updates the preview if cloning state has changed.
Returns void
consumeMouseEvent
-
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(); } }
Returns void
createGuide
-
Hook to override the creation of the Guide instance used by the class.
createPreviewShape
-
Creates the shape used to draw the preview for the given bounds.
destroyShapes
-
Destroy the preview and highlight shapes.
Returns void
getBoundingBox
-
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.
getCells
-
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[]
getDelta
-
Returns an Point that represents the vector for moving the cells for the given MouseEvent.
getGuideStates
-
Creates an array of cell states which should be used as guides.
getInitialCellForEvent
-
Hook to return initial cell for the given event.
Returns Cell | null
getPreviewBounds
-
Returns the Rectangle used as the preview bounds for moving the given cells.
isCellMoving
-
isCellMoving(cell: Cell): boolean
Returns true if the given cell is currently being moved.
Returns boolean
isCloneEnabled
-
isCloneEnabled(): boolean
isDelayedSelection
-
Hook to return true for delayed selections.
Returns boolean
isPropagateSelectionCell
-
Returns true if the given cell and parent should propagate selection state to the parent.
Returns boolean
isRemoveCellsFromParent
-
isRemoveCellsFromParent(): boolean
isSelectEnabled
-
isSelectEnabled(): boolean
isValidDropTarget
-
Returns true if the given cell is a valid drop target.
Returns boolean
mouseDown
-
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.
Returns void
mouseMove
-
Handles the event by highlighting possible drop targets and updating the preview.
Returns void
mouseUp
-
Handles the event by applying the changes to the selection cells.
Returns void
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
onDestroy
-
Destroys the handler and all its resources and DOM nodes.
Returns void
redrawHandles
-
Redraws the preview shape for the given states array.
Returns void
removeHint
-
Hooks for subclassers to hide details when the handler gets inactive.
Returns void
reset
-
Resets the state of this handler.
Returns void
resetPreviewStates
-
resetPreviewStates(states: CellState[][]): void
Resets the given preview states array.
Returns void
resume
-
Resumes the live preview.
Returns void
roundLength
-
roundLength(length: number): number
Hook for rounding the unscaled vector. This uses Math.round and keep only 2 digits.
Returns number
selectCellForEvent
-
Selects the given cell for the given MouseEvent.
selectDelayed
-
Implements the delayed selection for the given mouse event.
Returns void
setCloneEnabled
-
setCloneEnabled(value: boolean): void
Parameters
- value: boolean
Boolean that specifies the new clone enabled state.
Returns void
setEnabled
-
setEnabled(value: boolean): void
setHandlesVisibleForCells
-
setHandlesVisibleForCells( cells: Cell[], visible: boolean, force?: boolean,): void
Sets whether the handles attached to the given cells are visible.
Parameters
- cells: Cell[]
- 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
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
setMoveEnabled
-
setMoveEnabled(value: boolean): void
setRemoveCellsFromParent
-
setRemoveCellsFromParent(value: boolean): void
setSelectEnabled
-
setSelectEnabled(value: boolean): void
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
shouldRemoveParent
-
shouldRemoveParent(parent: Cell): boolean
Returns true if the given parent should be removed after removal of child cells.
Returns boolean
snap
-
Snaps the given vector to the grid and returns the given Point instance.
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
suspend
-
Suspends the live preview.
Returns void
updateHint
-
Hook for subclassers do show details while the handler is active.
Returns void
updateLivePreview
-
updateLivePreview(dx: number, dy: number): void
Updates the bounds of the preview shape.
Returns void
updatePreview
-
updatePreview(remote?: boolean): void
Updates the bounds of the preview shape.
Returns void
updatePreviewShape
-
updatePreviewShape(): void
Updates the bounds of the preview shape.
Returns void
useGuidesForEvent
-
Returns true if the guides should be used for the given MouseEvent.
This implementation returns Guide#isEnabledForEvent.
Returns boolean
On This Page
Constructors
Properties
Methods
|