Generic IInputMode implementation that can be used to move something in the canvas using the mouse.
Remarks
This implementation uses the hitTestable to determine where the user can begin dragging the selection. It will then use the positionHandler to delegate the actual work of moving the elements to.
This mode is exclusive by default.
Examples
Typically the MoveInputMode
is installed as child mode of a GraphEditorInputMode and can be retrieved from the moveSelectedItemsInputMode property.
const moveInputMode = mode.moveSelectedItemsInputMode
If one needs to execute some code after some items have been moved by the MoveInputMode, they can register a handler to its drag-finished event. The moved items can be retrieved from the affectedItems property:
mode.moveSelectedItemsInputMode.addEventListener('drag-finished', () => {
for (const item of mode.moveSelectedItemsInputMode.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
Constructors
Initializes a new instance of the MoveInputMode class.
Parameters
A map of options to pass to the method.
- enabled - boolean
- The enabled state of this input mode. This option sets the enabled property on the created object.
- 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.
- 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 constrains the current movement to be orthogonal or diagonal. 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 selection. 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.
- hoverRecognizer - function(EventArgs, unknown):boolean
- The event recognizer that determines whether the user is hovering over an item where the user can begin a move operation. This option sets the hoverRecognizer 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 selection. 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 the move. 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 selection. 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 selection 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 selection 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 selection via TOUCH input. 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.
- hitTestable - IHitTestable
- The IHitTestable that will be used by this mode to determine where the user may start dragging. This option sets the hitTestable property on the created object.
- positionHandler - IPositionHandler
- The IPositionHandler that will be used as fallback to handle the actual movement of the elements during the drag. This option sets the positionHandler property on the created object.
- validBeginCursor - Cursor
- The cursor to use while hovering above items that may be moved. This option sets the validBeginCursor property on the created object.
- moveCursor - Cursor
- The cursor to use while moving items. This option sets the moveCursor 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.
Properties
Gets an immutable snapshot of the IModelItems affected by the currently active gesture.
Remarks
When the gesture is starting and the positionHandler 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.moveSelectedItemsInputMode.addEventListener('drag-finished', () => {
for (const item of mode.moveSelectedItemsInputMode.affectedItems) {
// these items have been moved
}
})
Gets or sets the event recognizer that determines whether to start moving the selection.
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 selection 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 the move.
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 or sets the event recognizer that constrains the current movement to be orthogonal or diagonal.
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 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
Examples
mode.moveSelectedItemsInputMode.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 selection.
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 selection 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 IHitTestable that will be used by this mode to determine where the user may start dragging.
Gets or sets the event recognizer that determines whether the user is hovering over an item where the user can begin a move operation.
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 initial position where the dragging was initiated.
Gets or sets the event recognizer that determines whether to move the selection.
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 selection 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 or sets the IPositionHandler that will be used as fallback to handle the actual movement of the elements during the drag.
Remarks
Gets the priority of this input mode.
Remarks
Implements
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
.
Methods
Called when this mode is "armed".
Remarks
Cancels the editing of this mode.
Remarks
See Also
Implements
Returns the input mode context that will be passed to implementations that are called by this instance and require a context.
Returns
- ↪IInputModeContext
- A context to use for the implementations that are called by this instance.
Creates an IInputModeContext for use with the IPositionHandler interface for the upcoming drag operation.
Returns
- ↪IInputModeContext
- An instance of IInputModeContext.
Installs this mode into the given context that is provided by the canvas.
Remarks
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
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
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.
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.
Called 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.
Called 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.
Called 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.
Called 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-position-handler event.
Parameters
A map of options to pass to the method.
- evt - QueryPositionHandlerEventArgs
- The QueryPositionHandlerEventArgs 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.
Simulates the start of a drag and puts the state machine into the dragging state.
Remarks
location
.Parameters
A map of options to pass to the method.
- location - Point
- The location where the drag had been initialized.
Returns
- ↪Promise<IEnumerable<IModelItem>>
- A task that represents the asynchronous drag operation. The result of the task contains the affected items or
null
if the drag was canceled.
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
Uninstalls this mode from the given context.
Remarks
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
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 the drag has been canceled.
Occurs before the drag will be canceled.
Occurs once the drag has been finished.
Examples
mode.moveSelectedItemsInputMode.addEventListener('drag-finished', () => {
for (const item of mode.moveSelectedItemsInputMode.affectedItems) {
// these items have been moved
}
})
Occurs before the drag will be finished.
Occurs once the drag is initialized and has started.
Occurs once the drag is starting.
Occurs at the end of every drag.
Occurs at the start of every drag.
Occurs when a drag is recognized for the MoveInputMode.