An IInputMode implementation that can handle a collection of IHandles.
Remarks
This mode will render a visual representation of IHandles in the CanvasComponent and deal with mouse gestures that drag the visual representations accordingly.
This mode is exclusive by default.
Examples
Typically, the HandleInputMode
is installed as child mode of a GraphEditorInputMode and can be retrieved from the handleInputMode property.
const handleInputMode = mode.handleInputMode
If one needs to execute some code after some items have been moved by the HandleInputMode, he can register a handler to its drag-finished event. The moved items can be retrieved from the affectedItems property:
mode.handleInputMode.addEventListener('drag-finished', () => {
for (const item of mode.handleInputMode.affectedItems) {
// these items have been moved
}
})
mode.moveViewportInputMode.allowSinglePointerMovement = true
mode.createBendInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.createEdgeInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.handleInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.lassoSelectionInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.marqueeSelectionInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.moveSelectedItemsInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
Type Details
- yFiles module
- view
See Also
Constructors
Creates a new mode with no handles initially.
Parameters
A map of options to pass to the method.
- priority - number
- exclusive - boolean
- A value indicating whether this mode will be the only one running when it has the mutex. This option sets the exclusive property on the created object.
- enabled - boolean
- The enabled state of this input mode. This option sets the enabled property on the created object.
- useViewCoordinates - boolean
- A value indicating whether handles are drawn in view coordinates or intermediate coordinates. This option sets the useViewCoordinates property on the created object.
- disableSnappingRecognizer - function(EventArgs, unknown):boolean
- The event recognizer that determines whether to temporarily disable snapping. This option sets the disableSnappingRecognizer property on the created object.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
- enableSnappingRecognizer - function(EventArgs, unknown):boolean
- The event recognizer that determines whether to re-enable temporarily disabled snapping. This option sets the enableSnappingRecognizer property on the created object.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
- directionalConstraintRecognizer - function(EventArgs, unknown):boolean
- The event recognizer that can be used by handle implementations to constrain the handle movement. This option sets the directionalConstraintRecognizer property on the created object.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
- beginRecognizer - function(EventArgs, unknown):boolean
- The event recognizer that determines whether to start moving the handle. This option sets the beginRecognizer property on the created object.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
- moveRecognizer - function(EventArgs, unknown):boolean
- The event recognizer that determines whether to move the handle. This option sets the moveRecognizer property on the created object.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
- cancelRecognizer - function(EventArgs, unknown):boolean
- The event recognizer that determines whether to cancel moving the handle. This option sets the cancelRecognizer property on the created object.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
- finishRecognizer - function(EventArgs, unknown):boolean
- The event recognizer that determines whether to finish moving the handle. This option sets the finishRecognizer property on the created object.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
- beginRecognizerTouch - function(EventArgs, unknown):boolean
- The event recognizer that determines whether to start moving the handle via TOUCH input. This option sets the beginRecognizerTouch property on the created object.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
- moveRecognizerTouch - function(EventArgs, unknown):boolean
- The event recognizer that determines whether to move the handle via TOUCH input. This option sets the moveRecognizerTouch property on the created object.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
- finishRecognizerTouch - function(EventArgs, unknown):boolean
- The event recognizer that determines whether to finish moving the handle via touch. This option sets the finishRecognizerTouch property on the created object.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
- clickRecognizer - function(EventArgs, unknown):boolean
- The event recognizer that determines whether a handle was clicked. This option sets the clickRecognizer property on the created object.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
- clickRecognizerTouch - function(EventArgs, unknown):boolean
- The event recognizer that determines whether a handle was tapped via TOUCH input. This option sets the clickRecognizerTouch property on the created object.
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
- handles - IObservableCollection<IHandle>
- requestMutexOnPress - boolean
- Whether to request the mutex when beginRecognizer or beginRecognizerTouch was triggered. This option sets the requestMutexOnPress property on the created object.
- handlesRenderer - IObjectRenderer<HandlesRenderTag>
- The IObjectRenderer<HandlesRenderTag> that visualizes this input mode's handles. This option sets the handlesRenderer property on the created object.
- snapContext - GraphSnapContext
- The GraphSnapContext which manages snapping model items to certain coordinates (for instance, other items). This option either sets the value directly or recursively sets properties to the instance of the snapContext property on the created object.
See Also
Properties
Gets an immutable snapshot of the IModelItems affected by the currently modified handle gesture.
Remarks
When the gesture is starting and the currentHandle is initialized, the implementation can register the affected item(s) through the IModelItemCollector instance that is bound to the context available via its lookup.
Client code can register with the drag-started event, as well as the drag-finished event to get notified of the elements that may be or have been affected respectively by this input mode.
Property Value
Examples
mode.handleInputMode.addEventListener('drag-finished', () => {
for (const item of mode.handleInputMode.affectedItems) {
// these items have been moved
}
})
See Also
Gets or sets the event recognizer that determines whether to start moving the handle.
Remarks
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
Gets or sets the event recognizer that determines whether to start moving the handle via TOUCH input.
Remarks
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
Gets or sets the event recognizer that determines whether to cancel moving the handle.
Remarks
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
Gets or sets the event recognizer that determines whether a handle was clicked.
Remarks
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
Gets or sets the event recognizer that determines whether a handle was tapped via TOUCH input.
Remarks
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
Gets the installed controller.
Gets the handle that is currently being moved or null
otherwise.
Property Value
null
.Gets or sets the event recognizer that can be used by handle implementations to constrain the handle movement.
Remarks
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
See Also
Gets or sets the event recognizer that determines whether to temporarily disable snapping.
Remarks
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
See Also
Gets or sets the enabled state of this input mode.
Remarks
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.
Disabling this mode will hide the handles and prevent the user from interacting with them.
Examples
mode.handleInputMode.enabled = false
Gets or sets the event recognizer that determines whether to re-enable temporarily disabled snapping.
Remarks
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
See Also
Gets or sets a value indicating whether this mode will be the only one running when it has the mutex.
Remarks
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.
Gets or sets the event recognizer that determines whether to finish moving the handle.
Remarks
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
Gets or sets the event recognizer that determines whether to finish moving the handle via touch.
Remarks
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
Gets or sets the collection of IHandles this mode manages.
Gets or sets the IObjectRenderer<HandlesRenderTag> that visualizes this input mode's handles.
Remarks
When queried for an IVisualCreator to obtain the visualizations for the handles, this renderer is passed instances of HandlesRenderTag as render tag.
The default handlesRenderer is HandlesRenderer which automatically uses WebGL when WebGLGraphModelManager is set as graphModelManager, otherwise the SVG is used.
Property Value
Gets or sets the event recognizer that determines whether to move the handle.
Remarks
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
Gets or sets the event recognizer that determines whether to move the handle via TOUCH input.
Remarks
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
Retrieves the IInputModeContext this mode has been installed in.
Remarks
null
if this mode is currently not installed. Use createInputModeContext to obtain a context that has this IInputMode as the inputMode.Gets the priority of this input mode.
Remarks
See Also
Implements
Gets or sets whether to request the mutex when beginRecognizer or beginRecognizerTouch was triggered.
Remarks
true
this will discard other concurrent input modes when a handle was pressed. Otherwise, the mutex is only requested as soon as the drag gesture starts. The default is true
.See Also
Gets or sets the GraphSnapContext which manages snapping model items to certain coordinates (for instance, other items).
Remarks
If set to null
(the default) this input mode tries to obtain the GraphSnapContext from the IInputModeContext. To explicitly disable snapping, a GraphSnapContext implementation that is disabled needs to be set.
Default is null
.
Gets or sets a value indicating whether handles are drawn in view coordinates or intermediate coordinates.
Remarks
This only makes a difference if the projection is different from the IDENTITY transform.
The default value is to draw handles in the intermediate coordinate system.
See Also
Methods
Factory method that creates and adds a handle to this mode by wrapping a given IMutablePoint instance.
Remarks
Parameters
A map of options to pass to the method.
- location - IMutablePoint
- The point to use as a handle.
- cursor - Cursor
- The cursor to use.
- type - HandleType
- The type of the handle to create.
Returns
- ↪IHandle
- The handle created.
Will be called to unconditionally cancel all ongoing edits.
Remarks
This will be called prior to the uninstalling of this instance and when other input modes temporarily acquire the mutex.
In order to stop an active input mode manually, client code should use the following idiom:
if (!mode.tryStop()) {
mode.cancel()
}
Implements
Creates an IInputModeContext for use with the IHandle interface for the upcoming drag operation.
Returns
- ↪IInputModeContext
- An instance of IInputModeContext.
Helper method that yields a suitably configured InputModeEventArgs for this input mode.
Returns
- ↪InputModeEventArgs
- An input mode event argument that is configured for this instance.
Finds the closest hit handle for the given world coordinate pair.
Remarks
Parameters
A map of options to pass to the method.
- location - Point
- The coordinates in the world coordinate system.
Returns
- ↪IHandle?
- The closest handle that has been hit or
null
See Also
Finds the closest hit handle for the given world coordinate pair.
Remarks
Parameters
A map of options to pass to the method.
- location - Point
- The coordinates in the world coordinate system.
- pointerType - PointerType
- The pointer-type of the last input event.
Returns
- ↪IHandle?
- The closest handle that has been hit or
null
Calculates the offset between the given handle
's visual location and its logical location.
Calls handleClick of the handle
with the evt
.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The current input mode context.
- evt - ClickEventArgs
- Arguments describing the click.
- handle - IHandle
- The handle that was clicked.
Determines whether a given handle has been visually hit by the mouse at the given world coordinates.
Remarks
Parameters
A map of options to pass to the method.
- handle - IHandle
- The handle to check
- location - Point
- The view coordinates to check.
- distance - Point
- The distance of the handle to the location. In the default implementation, this is a tuple representing the x- and y-distance of the handle to the location.
- pointerType - PointerType
- The last event's pointer type to consider.
Returns
- ↪boolean
- Whether the handle has been hit.
Installs the visual representation of the handles into the canvas into the inputModeGroup.
Parameters
A map of options to pass to the method.
- 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
Implements
Invalidates the canvas this mode is currently installed in.
Returns whether this input mode has the mutex and the directionalConstraintRecognizer recognized a directional constrained move for the lastInputEvent.
Returns
- ↪boolean
true
, if this input mode has the mutex and the last input event was recognized by the directionalConstraintRecognizer,false
otherwise.
Returns whether this input mode has the mutex and the disableSnappingRecognizer recognized that snapping shall be temporarily disabled.
Returns
- ↪boolean
true
, if this input mode has the mutex and snapping is temporarily disabled,false
otherwise.
Called after cancel has been called.
Remarks
Can be overridden in subclasses to perform additional actions after the mode has been canceled.
This implementation does nothing.
Triggers the clicked event.
Remarks
Parameters
A map of options to pass to the method.
- evt - ClickEventArgs
- The event argument that contains context information.
Called after the active property of the installed ConcurrencyController has been set to true
.
Remarks
Can be overridden in subclasses to perform additional actions after the mode has been activated.
Overriding implementations should call the base implementation.
Called after the active property of the installed ConcurrencyController has been set to false
.
Remarks
Can be overridden in subclasses to perform additional actions after the mode has been deactivated.
Overriding implementations should call the base implementation.
Triggers the drag-canceled event.
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Triggers the drag-canceling event.
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Triggered once the drag has been finalized.
Remarks
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Triggered before the drag will be finalized.
Remarks
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Triggered at the end of each drag.
Remarks
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Triggered at the start of each drag.
Remarks
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Triggers the drag-started event.
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Triggers the drag-starting event.
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Raises the query-closest-handle event.
Parameters
A map of options to pass to the method.
- evt - QueryClosestHandleEventArgs
- The query-closest-handle instance containing the event data.
Called after tryStop has been called.
Remarks
Can be overridden in subclasses to perform additional actions after the mode has been stopped.
This implementation does nothing.
Method that can be used to initialize the dragging of a given handle manually.
Remarks
Parameters
A map of options to pass to the method.
- handle - IHandle
- The handle to be dragged.
Returns
Will be called to request a stop of the current editing progress.
Remarks
false
Returns
- ↪boolean
true
if and only if the editing has been stopped or there was no edit in progress
See Also
Implements
Removes the IRenderTreeElement that displays the handles from the canvas.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context to deregister from. This is the same instance that had been passed to install during installation.
Implements
Events
Occurs when a handle has been clicked or tapped.
Occurs when the drag has been canceled.
See Also
Occurs before the drag will be canceled.
See Also
Occurs once the drag has been finished.
Examples
mode.handleInputMode.addEventListener('drag-finished', () => {
for (const item of mode.handleInputMode.affectedItems) {
// these items have been moved
}
})
See Also
Occurs before the drag will be finished.
See Also
Occurs once the drag is initialized and has started.
See Also
Occurs once the drag is starting.
See Also
Occurs at the end of every drag.
See Also
Occurs at the start of every drag.