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 moveInputMode property.
If one needs to execute some code after some items have been moved by the MoveInputMode he can register a handler to its DragFinished event. The moved items can be retrieved from the affectedItems property:
mode.moveInputMode.addDragFinishedListener((sender, args) => {
for (const item of mode.moveInputMode.affectedItems) {
// these items have been moved
}
})
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.input.MoveInputMode
See Also
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(Object, EventArgs):boolean
The event recognizer that determines whether to temporarily disable snapping. This option sets the disableSnappingRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : 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
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
- enableSnappingRecognizer - function(Object, EventArgs):boolean
The event recognizer that determines whether to reenable temporarily disabled snapping. This option sets the enableSnappingRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : 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
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
- pressedRecognizer - function(Object, EventArgs):boolean
The event recognizer that determines whether to start moving the selection. This option sets the pressedRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : 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
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
- hoverRecognizer - function(Object, EventArgs):boolean
The event recognizer that determines whether to the user is hovering over an item where pressing can initialize a move operation. This option sets the hoverRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : 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
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
- draggedRecognizer - function(Object, EventArgs):boolean
The event recognizer that determines whether to move the selection. This option sets the draggedRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : 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
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
- cancelRecognizer - function(Object, EventArgs):boolean
The event recognizer that determines whether to cancel the move. This option sets the cancelRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : 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
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
- releasedRecognizer - function(Object, EventArgs):boolean
The event recognizer that determines whether to finish moving the selection. This option sets the releasedRecognizer property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : 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
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
- pressedRecognizerTouch - function(Object, EventArgs):boolean
The event recognizer that determines whether to start moving the selection via touch. This option sets the pressedRecognizerTouch property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : 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
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
- draggedRecognizerTouch - function(Object, EventArgs):boolean
The event recognizer that determines whether to move the selection via touch. This option sets the draggedRecognizerTouch property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : 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
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
- releasedRecognizerTouch - function(Object, EventArgs):boolean
The event recognizer that determines whether to finish moving the selection via touch. This option sets the releasedRecognizerTouch property on the created object.
Signature Details
function(eventSource: any, evt: EventArgs) : 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
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
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 that 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 - SnapContext
The snapContext which manages snapping model items to certain coordinates (for instance, other items). This option sets 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 DragStarted event, as well as the DragFinished event to get notified of the elements that may be or have been affected respectively by this input mode.
Examples
mode.moveInputMode.addDragFinishedListener((sender, args) => {
for (const item of mode.moveInputMode.affectedItems) {
// these items have been moved
}
})
See Also
Gets or sets the event recognizer that determines whether to cancel the move.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
Parameters
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
Gets the installed controller.
Gets or sets the event recognizer that determines whether to temporarily disable snapping.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
Parameters
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
See Also
Gets or sets the event recognizer that determines whether to move the selection.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
Parameters
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
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.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
Parameters
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
Gets or sets the enabled state of this input mode.
Remarks
Examples
Gets or sets the event recognizer that determines whether to reenable temporarily disabled snapping.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
Parameters
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
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 IHitTestable that will be used by this mode to determine where the user may start dragging.
See Also
Gets or sets the event recognizer that determines whether to the user is hovering over an item where pressing can initialize a move operation.
Remarks
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
Parameters
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
Gets the initial position where the dragging was initiated.
Gets the context instance this mode is currently installed in or null
if this instance is not installed.
Remarks
Implements
Gets or sets the cursor to use while moving items.
Gets or sets the IPositionHandler that will be used as fallback to handle that actual movement of the elements during the drag.
Remarks
See Also
Gets or sets the event recognizer that determines whether to start moving the selection.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
Parameters
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
See Also
Gets or sets the event recognizer that determines whether to start moving the selection via touch.
Remarks
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
Parameters
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
See Also
Gets the priority of this input mode.
Remarks
See Also
Implements
Gets or sets the event recognizer that determines whether to finish moving the selection.
Remarks
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
Parameters
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
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.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
Parameters
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
Gets or sets the snapContext 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 snapContext from the IInputModeContext. To explicitly disable snapping, a snapContext implementation that does nothing has to be set to this instance.
Default is null
.
Methods
Called when this mode is "armed".
Remarks
Cancels the editing of this mode.
Remarks
See Also
Implements
Creates an IInputModeContext for use with the IPositionHandler interface for the upcoming drag operation.
Returns
- ↪IInputModeContext
- An instance of IInputModeContext.
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.
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
Determines whether the given location is a valid start location for the move gesture.
Remarks
Parameters
A map of options to pass to the method.
- location - Point
- The location in the world coordinate system.
Returns
- ↪boolean
true
if at the given location it is valid to start the move gesture; otherwise,false
.
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 DragCanceled event.
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Triggers the DragCanceling 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 DragStarted event.
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Triggers the DragStarting event.
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Raises the QueryPositionHandler 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.
Called by the client in order to stop a 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.
See Also
Event Registration
addDragCanceledListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeDragCanceledListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs before the drag will be canceled.
See Also
Event Registration
addDragCancelingListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeDragCancelingListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs once the drag has been finished.
Examples
mode.moveInputMode.addDragFinishedListener((sender, args) => {
for (const item of mode.moveInputMode.affectedItems) {
// these items have been moved
}
})
See Also
Event Registration
addDragFinishedListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeDragFinishedListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs before the drag will be finished.
See Also
Event Registration
addDragFinishingListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeDragFinishingListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs at the end of every drag.
See Also
Event Registration
addDraggedListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeDraggedListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs at the start of every drag.
See Also
Event Registration
addDraggingListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeDraggingListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs once the drag is initialized and has started.
See Also
Event Registration
addDragStartedListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeDragStartedListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs once the drag is starting.
See Also
Event Registration
addDragStartingListener(function(this, InputModeEventArgs):void)
Event Deregistration
removeDragStartingListener(function(this, InputModeEventArgs):void)
Signature Details
function(sender: this, evt: InputModeEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - InputModeEventArgs
- An object that contains the event data.
Occurs when a drag is recognized for the MoveInputMode.
Remarks
See Also
Event Registration
addQueryPositionHandlerListener(function(this, QueryPositionHandlerEventArgs):void)
Event Deregistration
removeQueryPositionHandlerListener(function(this, QueryPositionHandlerEventArgs):void)
Signature Details
function(sender: this, evt: QueryPositionHandlerEventArgs)
Parameters
- sender - this
- The source of the event.
- evt - QueryPositionHandlerEventArgs
- An object that contains the event data.