C

LassoSelectionInputMode

An IInputMode implementation that provides support for lasso selections through mouse or touch gestures.
ImplementsInheritance Hierarchy

Remarks

This implementation will request the mutex as soon as it recognizes a mouse or touch drag.

By default, the lasso is a single freehand gesture. However, both a polyline path and mixed freehand/polyline paths are possible with different configuration.

Per default the visualization of the lasso selection region uses the secondary color of the set theme of CanvasComponent and uses the yfiles-lasso-template CSS class.

This mode is exclusive by default.

Examples

The LassoSelectionInputMode can easily be configured for different gestures, e.g. for a polyline path instead of the default freehand configuration:
const lassoSelectionInputMode =
  graphEditorInputMode.lassoSelectionInputMode
lassoSelectionInputMode.enabled = true
lassoSelectionInputMode.startSegmentRecognizer = EventRecognizers.ALWAYS
lassoSelectionInputMode.endSegmentRecognizer = (evt, sender) =>
  EventRecognizers.MOUSE_LEFT_DOWN(evt, sender) ||
  EventRecognizers.MOUSE_LEFT_UP(evt, sender)
lassoSelectionInputMode.dragSegmentRecognizer = (_, evt) =>
  evt instanceof PointerEventArgs &&
  (evt.pointerType == PointerType.MOUSE ||
    evt.pointerType == PointerType.PEN) &&
  (evt.eventType == PointerEventType.MOVE ||
    evt.eventType == PointerEventType.DRAG)
lassoSelectionInputMode.finishRecognizer =
  EventRecognizers.MOUSE_LEFT_DOUBLE_CLICK
lassoSelectionInputMode.finishRadius = 10

See Also

An example of how to style the lasso selection region with CSS is given in CSS Styling of Lasso Selection .

Developer's Guide

Members

Show:

Constructors

Creates a new instance of the lasso selection mode.

Parameters

Properties

Gets or sets the event recognizer that determines whether to start drawing the lasso.
The default recognizer detects primary down events for MOUSE or PEN.
final

See Also

Developer's Guide
API
beginRecognizerTouch
Gets or sets the event recognizer that determines whether to start drawing the lasso with TOUCH input.
The default recognizer is TOUCH_PRIMARY_LONG_PRESS which reacts to the user making touch contact with the main touch device. Using TOUCH_PRIMARY_DOWN allows for an intuitive alternative configuration.
final

See Also

Developer's Guide
API
beginRecognizer
Gets or sets the event recognizer that determines whether to cancel lasso selection.
The default recognizer reacts to CANCEL and DRAG_CAPTURE_LOST events, or ESCAPE_DOWN, or secondary up events for MOUSE or PEN.
final
Gets the installed controller.
protectedreadonlyfinal
Gets or sets the event recognizer that determines whether to drag the lasso free hand.
The default recognizer detects primary DRAG events for MOUSE or PEN.
final

See Also

Developer's Guide
API
dragFreeHandRecognizerTouch
Gets or sets the event recognizer that determines whether to drag the lasso free hand with TOUCH input.
The default recognizer is TOUCH_PRIMARY_DRAG.
final

See Also

Developer's Guide
API
dragFreeHandRecognizer
Gets or sets the event recognizer that determines whether to drag a straight-line segment for the lasso.
The default recognizer is MOUSE_MOVE.
final

See Also

Developer's Guide
API
dragSegmentRecognizerTouch
Gets or sets the event recognizer that determines whether to drag a straight-line segment for the lasso with TOUCH input.
The default recognizer is NEVER which means that the straight-line segment will only be finished when switching back to free hand creation or when finishing the gesture.
final

See Also

Developer's Guide
API
dragSegmentRecognizer
Gets or sets the enabled state of this input mode.
Clients can use this property to disable or reenable this instance. This will set the enabled property of the installed controller so a disabled instance should never try to acquire the input mutex.
Gets or sets the event recognizer that determines whether to end a segment and switch from segment to freehand mode.
The default recognizer detects primary down events for MOUSE or PEN. However, since startSegmentRecognizer is disabled, this has no effect in the default configuration.
final

See Also

Developer's Guide
API
endSegmentRecognizerTouch
Gets or sets the event recognizer that determines whether to end a segment and switch from segment to freehand mode for TOUCH input.
The default recognizer is TOUCH_PRIMARY_DOWN. However, since startSegmentRecognizerTouch is disabled, this has no effect in the default configuration.
final

See Also

Developer's Guide
API
endSegmentRecognizer
Gets or sets a value indicating whether this mode will be the only one running when it has the mutex.

The value of this property will be delegated to the exclusive property of the controller.

If this mode is marked as exclusive and has the mutex, all other modes added to the same MultiplexingInputMode will be deactivated. Otherwise, it will always run concurrently with all other modes.

final
Gets or sets the cursor to use during the dragging of the lasso when extendSelectionRecognizer is active.
The default is null meaning that lassoCursor will be used instead.
conversionfinal
Gets or sets the event recognizer that determines if a selection is deemed an additive selection gesture, adding to the current selection.

If the event recognizer returns true for the current gesture, the elements which will be selected with that gesture will be added to the current selection. Otherwise, the selection will be cleared before adding the newly selected element.

Note that this will only have an influence on the currently shown lassoCursor and the value of the selectionPolicy property. It is up to the handler of the drag-finished event to implement the selection behavior based on the policy value.

The default detects the current platform and delegates either to META_IS_DOWN (macOS) or CTRL_IS_DOWN (other platforms).

final
Gets or sets the radius in view coordinates around the startLocation where the lasso selection can be finished.

A value of 0 (the default) disables ending the gesture near the startLocation and also disables showing the indicator.

Default is 0.

final

See Also

Developer's Guide
Gets or sets the event recognizer that determines whether to finish the gesture anywhere independent of the finishRadius.
Gets or sets the event recognizer that determines whether to finish the touch gesture anywhere independent of the finishRadius.
Gets or sets the event recognizer that determines whether to finish the gesture when the pointer is within the finishRadius of the startLocation.
This recognizer is always combined with a check whether the input coordinates are within finishRadius around startLocation.
final

See Also

Developer's Guide
API
finishRegionRecognizerTouch, finishRecognizer, finishRecognizerTouch
Gets or sets the event recognizer that determines whether to finish the touch gesture when the pointer is within the finishRadius of the startLocation.

This recognizer is always combined with a check whether the input coordinates are within finishRadius around startLocation.

The default recognizer is TOUCH_PRIMARY_UP.

Due to the default recognizer for finishRecognizerTouch and the default value for finishRadius this is not used unless the mentioned properties are changed.

final

See Also

Developer's Guide
API
finishRegionRecognizer, finishRecognizer, finishRecognizerTouch
Gets or sets the IObjectRenderer<LassoPathFinishRegionRenderTag> that visualizes the region around the startLocation where the lasso may be finished.
When queried for an IVisualCreator to obtain the visualizations for the finish region, this renderer is passed instances of LassoPathFinishRegionRenderTag as render tag.
final

Property Value

The finish region renderer.

See Also

Developer's Guide
Gets or sets the cursor to use during the dragging of the lasso.
Retrieves the IInputModeContext this mode has been installed in.
The value will be null if this mode is currently not installed.
protectedreadonlyfinal
Gets the priority of this input mode.
The priority will influence the order in which the modes will be installed into the CanvasComponent. The lower the priority value, the earlier it will be installed. If two modes are using the same priority value, the first one to be registered will be installed earlier.
final
Gets the current or last selection path.
readonlyfinal
Gets the current or last SelectionPolicy as determined by the EventRecognizers.
readonlyfinal

See Also

Developer's Guide
Gets the location where the beginRecognizer was triggered and the lasso selection started.
protectedreadonlyfinal
Gets or sets the event recognizer that determines whether to switch from freehand to segment mode.
The default recognizer is NEVER, which locks this mode in freehand-only mode. However, this can be set differently to allow for a mixed freehand/segment mode.
final

See Also

Developer's Guide
API
startSegmentRecognizerTouch
Gets or sets a recognizer determining when to switch from freehand to segment mode for TOUCH input.
The default recognizer is NEVER, which locks this mode in freehand-only mode. However, this can be set differently to allow for a mixed freehand/segment mode.
final

See Also

Developer's Guide
API
startSegmentRecognizer
Gets or sets the cursor to use during the dragging of the lasso when subtractSelectionRecognizer is active.
The default is null meaning that lassoCursor will be used instead.
conversionfinal
Gets or sets the event recognizer that determines if a selection is deemed a subtractive selection gesture, removing the selection state from the current selection.

If the event recognizer returns true for the current gesture, the elements which will be selected with that gesture will be removed from the current selection.

Note that this will only have an influence on the currently shown lassoCursor and the value of the selectionPolicy property. It is up to the handler of the drag-finished event to implement the selection behavior based on the policy value.

The default is SHIFT_IS_DOWN.

final
Gets or sets the cursor to use during the dragging of the lasso when toggleSelectionRecognizer is active.
The default is null meaning that lassoCursor will be used instead.
conversionfinal
Gets or sets the event recognizer that determines if a selection is deemed a toggle selection gesture, inverting the selection for the elements in the lasso.

If the event recognizer returns true for the current gesture, the elements in the lasso will get their selection state toggled.

Note that this will only have an influence on the currently shown lassoCursor and the value of the selectionPolicy property. It is up to the handler of the drag-finished event to implement the selection behavior based on the policy value.

The default is ALT_IS_DOWN.

final
Gets or sets the cursor to use when beginning the dragging of the lasso is valid.
The default is null
conversionfinal

See Also

Developer's Guide
Gets or sets the event recognizer that determines whether it is valid to begin drawing the lasso.
The default recognizer is ALWAYS.
final

See Also

Developer's Guide
Gets or sets the cursor to use when hovering over a valid end location.

Methods

Cancels any pending lasso selection.
Helper method that yields a suitably configured LassoSelectionEventArgs for this input mode.
Installs this mode into the given context that is provided by the canvas.

In general a mode can only be installed into a single canvas at all times.

This method is called to initialize this instance. Subclasses should override this method to register the corresponding event handler delegates for the various input events they need to register with.

Overriding implementations should call the base implementation, first.

Parameters

context: IInputModeContext
The context that this instance shall be installed into. The same instance will be passed to this instance during uninstall. A reference to the context may be kept and queried during the time the mode is installed.
controller: ConcurrencyController
The controller for this mode.

See Also

API
uninstall
Used by the finishRecognizer and finishRecognizerTouch to check the current cursor position.
This method checks if the distance from location to the startLocation is less than finishRadius in view coordinates.
protected

Parameters

location: Point
The location in world coordinates that should be checked.

Return Value

boolean
true if the location is a valid end location; otherwise, false.
Called after cancel has been called.

Can be overridden in subclasses to perform additional actions after the mode has been canceled.

This implementation does nothing.

protected
Called after the active property of the installed ConcurrencyController has been set to true.

Can be overridden in subclasses to perform additional actions after the mode has been activated.

Overriding implementations should call the base implementation.

protected
Called after the active property of the installed ConcurrencyController has been set to false.

Can be overridden in subclasses to perform additional actions after the mode has been deactivated.

Overriding implementations should call the base implementation.

protected
Triggers the drag-canceled event.
protected

Parameters

evt: LassoSelectionEventArgs
The event argument that contains context information.
Triggers the drag-canceling event.
protected

Parameters

evt: LassoSelectionEventArgs
The event argument that contains context information.
Called once the drag has been finalized.
This method triggers the drag-finished event.
protected

Parameters

evt: LassoSelectionEventArgs
The event argument that contains context information.
Called before the drag will be finalized.
This method triggers the drag-finishing event.
protected

Parameters

evt: LassoSelectionEventArgs
The event argument that contains context information.
Called at the end of each drag.
This method triggers the dragged event.
protected

Parameters

evt: LassoSelectionEventArgs
The event argument that contains context information.
Called at the start of each drag.
This method triggers the dragging event.
protected

Parameters

evt: LassoSelectionEventArgs
The event argument that contains context information.
Triggers the drag-started event.
protected

Parameters

evt: LassoSelectionEventArgs
The event argument that contains context information.
Triggers the drag-starting event.
protected

Parameters

evt: LassoSelectionEventArgs
The event argument that contains context information.
Called after tryStop has been called.

Can be overridden in subclasses to perform additional actions after the mode has been stopped.

This implementation does nothing.

protected
Will be called to request a stop of the current editing progress.
This should stop the current edit, if one is in progress, and possibly commit all pending changes. If stopping is not possible, this method can return false

Return Value

boolean
true if and only if the editing has been stopped or there was no edit in progress
Uninstalls this mode from the given context.

This code should clean up all changes made to the canvas in the install method. After a mode has been uninstalled it can be installed again into the same or another canvas.

Overriding implementations should call the base implementation after their own code.

Parameters

context: IInputModeContext
The context to deregister from. This is the same instance that had been passed to install during installation.

Events

Occurs when the drag has been canceled.
context: IInputModeContext
Gets the context for the current event.
policy: SelectionPolicy
Gets a value determining the SelectionPolicy that is currently set by the user.
Occurs before the drag will be canceled.
context: IInputModeContext
Gets the context for the current event.
policy: SelectionPolicy
Gets a value determining the SelectionPolicy that is currently set by the user.
Occurs when the drag has been finished.
context: IInputModeContext
Gets the context for the current event.
policy: SelectionPolicy
Gets a value determining the SelectionPolicy that is currently set by the user.

See Also

Developer's Guide
Occurs before the drag will be finished.
context: IInputModeContext
Gets the context for the current event.
policy: SelectionPolicy
Gets a value determining the SelectionPolicy that is currently set by the user.
Occurs once the drag is initialized and has started.
context: IInputModeContext
Gets the context for the current event.
policy: SelectionPolicy
Gets a value determining the SelectionPolicy that is currently set by the user.
Occurs once the drag is starting.
context: IInputModeContext
Gets the context for the current event.
policy: SelectionPolicy
Gets a value determining the SelectionPolicy that is currently set by the user.
Occurs at the end of every drag.
context: IInputModeContext
Gets the context for the current event.
policy: SelectionPolicy
Gets a value determining the SelectionPolicy that is currently set by the user.
Occurs at the start of every drag.
context: IInputModeContext
Gets the context for the current event.
policy: SelectionPolicy
Gets a value determining the SelectionPolicy that is currently set by the user.