C

NodeDropInputMode

An ItemDropInputMode<T> specialized to the drag and drop of INodes.

Remarks

By default, this input mode copies the layout, style, tag, ports, and labels of the draggedItem to the new node.

It can visualize a preview of the draggedItem during the drag operation, and supports snapping via the snapContext and highlighting of the dropTarget via a HighlightIndicatorManager<T>. In addition, it supports dragging nodes into groups and, optionally, folders. In this case the isValidParentPredicate will be queried if the dropped upon node is actually a valid parent.

Examples

Typically the NodeDropInputMode is installed as child mode of a GraphEditorInputMode and can be retrieved from the nodeDropInputMode property.
Getting the NodeDropInputMode from its parent input mode
const nodeDropInputMode = mode.nodeDropInputMode

See Also

Developer's Guide

Members

Show:

Constructors

Initializes a new instance of the NodeDropInputMode class for the given data type.

This instance fires events only if a drag operation carries DragDropItem of the given type.

When no transferType is provided, it defaults to DEFAULT_TRANSFER_TYPE so it fires only for DragDropItem carrying this data type. For example, startDrag initiates such a drag operation.

Parameters

transferType: string
A list of types for which this input mode is registered.

Properties

Gets or sets a value indicating whether nodes can be dropped on collapsed folder nodes.
If this property is set to true, dropping nodes on collapsed folder nodes will create the node inside the folder node in the master graph. In that case the item-created event will yield the node in the masterGraph. The node will not be contained in the currently visible graph. By default, this feature is disabled. In any case, the isValidParentPredicate will be queried additionally if the node is a valid parent.
final

Property Value

true if folder node parents are allowed; false otherwise.

See Also

Developer's Guide
Gets or sets a value indicating whether nodes can be dropped onto nodes that are not group nodes.
If this property is enabled, dropping a node on a non-group node will effectively convert the non-group node to a real group node. By default, this feature is disabled. In any case, the isValidParentPredicate will be queried additionally if the node is a valid parent.
final

Property Value

true if non-group node parents are allowed as valid drop targets; false otherwise.

See Also

Developer's Guide
Gets or sets a value indicating whether to capture pointer input during drag operations.
The default is true and thus prevents pointer events from being processed by visuals in the canvas.
final

Property Value

true if pointer input should be captured during the drag; false otherwise.
Gets the installed controller.
protectedreadonlyfinal
Gets or sets the event recognizer that determines whether to disable snapping temporarily.
final

Property Value

The disable snapping recognizer. The default recognizer checks for a pressed using CONTROL_KEY.
Gets or sets the DragDropEffects that will be used for drags on the canvas.
conversionfinal
Gets the currently dragged IModelItem instance.

This implementation simply tries to cast the dropData to INode.

If native drag and drop is used, the value of this property is always null. This is because the protected mode prevents access to the actual data during dragover.

protectedreadonly
Gets the data carried by a drag operation.
This is only valid, if a drag entered the CanvasComponent first.
readonly
Gets the pointer position after dropping an item.
The position is returned in world coordinates according to the CanvasComponent into which this input mode is installed.
readonlyfinal
Gets the drop target at snappedPointerPosition
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.

Examples

Disabling the NodeDropInputMode on its parent input mode
mode.nodeDropInputMode.enabled = false
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 whether the drop target is highlighted.
Gets a value indicating whether a drag operation is currently in progress.
readonlyfinal
Gets or sets the callback for testing whether a dragged node should be created as a group node.
The default implementation returns false always. Can be set to a different value to implement custom group node detection.
final

See Also

Developer's Guide
Gets or sets the callback for testing whether an existing node in the graph can be used as a valid parent node in the context of grouping.
The default implementation returns true always. Can be set to a different value to implement custom group node detection. Note that the node passed to the predicate may be null to indicate that the node will be placed at the root of the hierarchy.
final

See Also

Developer's Guide
API
allowNonGroupNodeAsParent, allowFolderNodeAsParent
Gets or sets the callback for item creation.
Gets the last processed drag event argument.
readonlyfinal
Retrieves the IInputModeContext this mode has been installed in.
The value will be null if this mode is currently not installed. Use createInputModeContext to obtain a context that has this IInputMode as the inputMode.
protectedreadonlyfinal
Gets the current pointer position during drag operations.
The position is returned in world coordinates according to the CanvasComponent into which this input mode is installed.
readonlyfinal
Gets the graph displayed as item preview.
protectedreadonlyfinal

Property Value

The preview graph or null if no preview is displayed at the moment.

See Also

Developer's Guide
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 or sets whether a preview of the dragged element is displayed during the drag.
Gets or sets the GraphSnapContext which is used to snap the dragged element during the drag.
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.
final

See Also

Developer's Guide
Gets the current snapped pointer position during drag operations.
The position is returned in world coordinates according to the CanvasComponent into which this input mode is installed. If snappingEnabled is false, this value corresponds with pointerPosition.
readonlyfinal
Gets or sets whether dragged items are snapped.
Gets or sets the IHitTestable that determines whether the given location is a valid drop location.
final

Property Value

The hit testable that yields true for valid drop locations.

See Also

Developer's Guide

Methods

Called to adjust the dropEffect accordingly.
protected

Parameters

evt: DragEventArgs
The event args of the drag event to adjust the effects for.

Return Value

boolean
true if the drag event is handled by this input mode.
Cleanly cancels this mode.
Cleanup method that calls cleanUpSnapContext, cleanUpPreview and cleanUpDropTarget.
This method should be called for cleanup actions after a drag/drop gesture has been finished or canceled.
protected
Cleans up the drop target and its highlighting.
Cleans up the item preview.
Cleans up the snap context.
Callback registered on the SnapContext that collects SnapResults for the dragged element.
The default implementation doesn't collect any snap results.
protected

Parameters

evt: CollectSnapResultsEventArgs
The arguments describing the movement SnapResults shall be collected for.
source: any
The SnapContext this callback is registered at.
Creates an implementation of IInputModeContext that is specific to this mode.

This is needed for events that are triggered by this InputMode to signalize where the event is coming from. A common usage for this is for example in isHit calls.

The result can be given to isHit or enumerateHits to let implementations of IHitTestable get access to the current IInputModeContext. This can be done by looking up IInputModeContext from the ICanvasContext's lookup method or simply downcasting.

protected

Return Value

IInputModeContext
A readily configured IInputModeContext.
Helper method that yields a suitably configured InputModeEventArgs for this input mode.
protected

Return Value

InputModeEventArgs
An input mode event argument that is configured for this instance.
Creates the node in the graph after it's been dropped.
This method is called by the itemCreator that is set as default on this class.
protected

Parameters

context: IInputModeContext
The context for which the node should be created.
graph: IGraph
The graph in which to create the item.
node: INode
The node that was dragged and should therefore be created.
dropTarget: IModelItem
The IModelItem on which the node is dropped.
layout: Rect
The bounds of the new node.

Return Value

INode
a newly created node.

See Also

Developer's Guide
Returns the drop target at the specified location.
The drop target is highlighted, if highlightDropTarget is enabled. By default, null is returned.
protected

Parameters

dragLocation: Point
The location to return the drop target for.

Return Value

IModelItem
The drop target at the specified location or null if no drop target can be found.
Calculates the layout of the new node.
In this implementation, the pointer location is used as the center of the node. Can be overridden in a child class to implement a different layout.
protected

Parameters

pointerLocation: Point
Current pointer position
size: Size
Size of the node

Return Value

Rect
a Rect with the given size and the pointer location as center.

See Also

Developer's Guide
Initializes the drop target.
Initializes the item preview.
This method is called by onDragEntered. If a preview shall be displayed, the previewGraph is initialized and populatePreviewGraph is called.
protected

See Also

Developer's Guide
Initializes the snapping context.
This method is called by onDragEntered
protected
Installs this mode into the given canvas.
Clients should not call this method as this is handled by the framework.

Parameters

context: IInputModeContext
the context to install this mode into
controller: ConcurrencyController
The controller for this mode.

See Also

API
CanvasComponent
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
Called once a drag has been dropped on the canvas.
protected

Parameters

evt: InputModeEventArgs
The event argument that contains context information.
Called once a drag has entered the canvas.

Parameters

evt: InputModeEventArgs
The event argument that contains context information.
Called whenever a drag is over the canvas.
protected

Parameters

evt: InputModeEventArgs
The event argument that contains context information.
Called once a drag has left the canvas.
protected

Parameters

evt: InputModeEventArgs
The event argument that contains context information.
Called whenever a new item is created.
protected

Parameters

evt: InputModeItemEventArgs<INode>
The InputModeItemEventArgs<TModelItem> containing the new item.
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
Subclasses shall fill the specified graph that is used to preview the dragged item.
protected

Parameters

previewGraph: IGraph
The preview graph to fill.
Sets the drag location and calls updatePreview to update the layout of item preview based on the pointer coordinates and the results of the snapContext.
protected

Parameters

location: Point
The current location of the pointer in world coordinates.
Overridden to only return true if this instance does not currently have the input mutex.

Return Value

boolean
true iff this instance does not own the mutex.
Uninstalls this mode from the canvas.
Clients should not call this method as this is handled by the framework.

Parameters

context: IInputModeContext
the context
Calls getDropTarget for snappedPointerPosition and sets the returned item as dropTarget.
If highlightDropTarget is enabled, the highlight is updated as well.
protected

Parameters

dragLocation: Point
The location to update the drop target for.
Subclasses shall update the previewGraph so the dragged item is displayed at the specified dragLocation.
protected

Parameters

previewGraph: IGraph
The preview graph to update.
dragLocation: Point
The current drag location.

Events

Occurs when a drag operation is dropped onto the CanvasComponent into which this instance is installed.

No event is raised

  • if this instance is not enabled,
  • if another concurrent input mode is active or
  • the data from the drag operation does not conform to the expected type.

To get additional data for the event, clients should use the sender which is set to the sending DropInputMode. The EventArgs provide no useful data.

Properties of

InputModeEventArgs
context: IInputModeContext
Gets the context for the current event.

See Also

Developer's Guide
Occurs when a drag operation enters the CanvasComponent into which this instance is installed.

No event is raised

  • if this instance is not enabled,
  • if another concurrent input mode is active or
  • the data from the drag operation does not conform to the expected type.

To get additional data for the event, clients should use the sender which is set to the sending DropInputMode. The EventArgs provide no useful data.

Properties of

InputModeEventArgs
context: IInputModeContext
Gets the context for the current event.

See Also

Developer's Guide
Occurs when a drag operation leaves the CanvasComponent into which this instance is installed.

No event is raised

  • if this instance is not enabled,
  • if another concurrent input mode is active or
  • the data from the drag operation does not conform to the expected type.

To get additional data for the event, clients should use the sender which is set to the sending DropInputMode. The EventArgs provide no useful data.

Properties of

InputModeEventArgs
context: IInputModeContext
Gets the context for the current event.

See Also

Developer's Guide
Occurs when a drag operation drags over the CanvasComponent into which this instance is installed.

No event is raised

  • if this instance is not enabled,
  • if another concurrent input mode is active or
  • the data from the drag operation does not conform to the expected type.

To get additional data for the event, clients should use the sender which is set to the sending DropInputMode. The EventArgs provide no useful data.

Properties of

InputModeEventArgs
context: IInputModeContext
Gets the context for the current event.

See Also

Developer's Guide
Occurs when a new item gets created by this input mode.
context: IInputModeContext
Gets the context for the current event.
item: TModelItem
Gets the item which has been created or changed.

Constants

The transfer type to which the NodeDropInputMode and its startDrag method is configured by default.

Static Methods

Starts a drag and drop operation for a INode.

This method creates a DragSource, and then invokes startDrag with a DragDropItem that contains the node and the corresponding type.

If useCssCursors is enabled, the following CSS classes are assigned to elements hovered during a drag operation, depending on the allowed drag-drop operations for these elements:

  • yfiles-cursor-dragdrop-move
  • yfiles-cursor-dragdrop-link
  • yfiles-cursor-dragdrop-all
  • yfiles-cursor-dragdrop-no-drop
static

Parameters

dragSource: any
The source of the drag operation.
node: INode
The node to drag.
dragDropEffects?: DragDropEffects
The allowed drag drop effects.
useCssCursors?: boolean
Whether to adjust the classes of elements being hovered over during the drag. The default is true.
dragPreview?: any
Optional element that should be shown during dragging, e.g. outside of the GraphComponent. Note that this feature requires support for CSS pointer-events and should not be used in browsers that do not support it.

Return Value

DragSource
The new DragSource instance.

See Also

Developer's Guide
API
startDrag, DragDropItem