An ItemDropInputMode<T> specialized to the drag and drop of IPorts.
Remarks
Examples
PortDropInputMode
is installed as child mode of a GraphEditorInputMode and can be retrieved from the portDropInputMode property.const portDropInputMode = mode.portDropInputMode
Type Details
- yFiles module
- view
Constructors
Initializes a new instance of the PortDropInputMode class for the given data type.
Remarks
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
A map of options to pass to the method.
- transferType - string
- A list of types for which this input mode is registered.
- isValidPortOwnerPredicate - function(IPortOwner, IPort):boolean
- The callback for testing whether an existing port owner in the graph can be used as owner for the currently dragged port. This option sets the isValidPortOwnerPredicate property on the created object.
Signature Details
function(arg1: IPortOwner, arg2: IPort) : boolean
Encapsulates a method that has two parameters and returns a value of the type specified by theTResult
parameter.Parameters
- arg1 - IPortOwner
- The first parameter of the method that this delegate encapsulates.
- arg2 - IPort
- The second parameter of the method that this delegate encapsulates.
Returns
- boolean
- The return value of the method that this delegate encapsulates.
- useLocationForParameter - boolean
- A value indicating whether the default implementation of getNewPortLocationModelParameter should determine a parameter that best matches the location of the dropped port, or if it should directly use the parameter stored in the dropped item. This option sets the useLocationForParameter property on the created object.
- showPreview - boolean
- Whether a preview of the dragged element is displayed during the drag. This option sets the showPreview property on the created object.
- snappingEnabled - boolean
- Whether dragged items are snapped. This option sets the snappingEnabled property on the created object.
- disableSnappingRecognizer - function(EventArgs, unknown):boolean
- The event recognizer that determines whether to disable snapping temporarily. 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.
- highlightDropTarget - boolean
- Whether the drop target is highlighted. This option sets the highlightDropTarget property on the created object.
- snapContext - GraphSnapContext
- The GraphSnapContext which is used to snap the dragged element during the drag. This option either sets the value directly or recursively sets properties to the instance of the snapContext property on the created object.
- itemCreator - function(IInputModeContext, IGraph, any, IModelItem, Point):IPort
- The callback for item creation. This option sets the itemCreator property on the created object.
Signature Details
function(context: IInputModeContext, graph: IGraph, dropData: any, dropTarget: IModelItem, dropLocation: Point) : IPort
Creates a copy of the dragged item in the graph at the specified location.Parameters
- context - IInputModeContext
- The context for which the item should be created.
- graph - IGraph
- The
in which to create the item. - dropData - any
- The data containg the item that was dragged and should therefore be created.
- dropTarget - IModelItem
- The
on which the item is dropped. - dropLocation - Point
- The location the item should be created.
Returns
- IPort
- The item that has been created, or
null
if no item should be created.
- 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.
- dragDropEffect - DragDropEffects
- The DragDropEffects that will be used for drags on the canvas. This option sets the dragDropEffect property on the created object.
- validDropHitTestable - IHitTestable
- The IHitTestable that determines whether the given location is a valid drop location. This option sets the validDropHitTestable property on the created object.
- capturePointerInputDuringDrag - boolean
- A value indicating whether to capture pointer input during drag operations. This option sets the capturePointerInputDuringDrag property on the created object.
Properties
Gets or sets a value indicating whether to capture pointer input during drag operations.
Remarks
true
and thus prevents pointer events from being processed by visuals in the canvas.Property Value
true
if pointer input should be captured during the drag; false
otherwise.Defined in
Gets the installed controller.
Defined in
Gets or sets the event recognizer that determines whether to disable snapping temporarily.
Property Value
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.
Defined in
Gets or sets the DragDropEffects that will be used for drags on the canvas.
Defined in
Gets the currently dragged IModelItem instance.
Gets the data carried by a drag operation.
Gets the pointer position after dropping an item.
Remarks
Defined in
Gets the drop target at snappedPointerPosition
Gets or sets the enabled state of this input mode.
Remarks
Examples
mode.nodeDropInputMode.enabled = false
Defined in
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.
Defined in
Gets or sets whether the drop target is highlighted.
Defined in
Gets a value indicating whether a drag operation is currently in progress.
Defined in
Gets or sets the callback for testing whether an existing port owner in the graph can be used as owner for the currently dragged port.
Remarks
The default implementation checks whether a valid port model parameter could be found for the combination of port owner and dragged port.
Note that during native drag and drop, draggedItem is always null and cannot be used for this check.
Signature Details
function(arg1: IPortOwner, arg2: IPort) : boolean
TResult
parameter.Parameters
- arg1 - IPortOwner
- The first parameter of the method that this delegate encapsulates.
- arg2 - IPort
- The second parameter of the method that this delegate encapsulates.
Returns
- boolean
- The return value of the method that this delegate encapsulates.
Gets or sets the callback for item creation.
Remarks
Signature Details
function(context: IInputModeContext, graph: IGraph, dropData: any, dropTarget: IModelItem, dropLocation: Point) : IPort
Parameters
- context - IInputModeContext
- The context for which the item should be created.
- graph - IGraph
- The
in which to create the item. - dropData - any
- The data containg the item that was dragged and should therefore be created.
- dropTarget - IModelItem
- The
on which the item is dropped. - dropLocation - Point
- The location the item should be created.
Returns
- IPort
- The item that has been created, or
null
if no item should be created.
Defined in
Gets the last processed drag event argument.
Defined in
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.Defined in
Gets the current pointer position during drag operations.
Remarks
Defined in
Gets the graph displayed as item preview.
Property Value
null
if no preview is displayed at the moment.Defined in
Gets the priority of this input mode.
Remarks
Implements
Gets or sets whether a preview of the dragged element is displayed during the drag.
Defined in
Gets or sets the GraphSnapContext which is used to snap the dragged element during the drag.
Remarks
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.Defined in
Gets the current snapped pointer position during drag operations.
Remarks
Defined in
Gets or sets whether dragged items are snapped.
Defined in
Gets or sets a value indicating whether the default implementation of getNewPortLocationModelParameter should determine a parameter that best matches the location of the dropped port, or if it should directly use the parameter stored in the dropped item.
Remarks
false
, which means the parameter from the dropped port will be used directly.Gets or sets the IHitTestable that determines whether the given location is a valid drop location.
Methods
Called to adjust the dropEffect accordingly.
Parameters
A map of options to pass to the method.
- evt - DragEventArgs
- The event args of the drag event to adjust the effects for.
Returns
- ↪boolean
true
if the drag event is handled by this input mode.
Overrides
Cleanly cancels this mode.
Implements
Cleanup method that calls cleanUpSnapContext, cleanUpPreview and cleanUpDropTarget.
Remarks
Defined in
Cleans up the drop target and its highlighting.
Defined in
Cleans up the item preview.
Overrides
Cleans up the snap context.
Defined in
Callback registered on the SnapContext that collects SnapResults for the dragged element.
Remarks
Parameters
A map of options to pass to the method.
- evt - CollectSnapResultsEventArgs
- The arguments describing the movement SnapResults shall be collected for.
- source - any
- The SnapContext this callback is registered at.
Overrides
Creates an implementation of IInputModeContext that is specific to this mode.
Remarks
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.
Returns
- ↪IInputModeContext
- A readily configured IInputModeContext.
See Also
Overrides
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.
Defined in
createPort
(context: IInputModeContext, graph: IGraph, draggedPort: IPort, dropTarget: IPortOwner, parameter: IPortLocationModelParameter) : IPortCreates the port in the graph after it has been dropped.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context for which the port should be created.
- graph - IGraph
- The graph in which to create the port.
- draggedPort - IPort
- The port that was dragged and should therefore be created.
- dropTarget - IPortOwner
- The IPortOwner on which the port is dropped.
- parameter - IPortLocationModelParameter
- The IPortLocationModelParameter of the new port.
Returns
- ↪IPort?
- a newly created label.
Looks for a valid port owner at the dragLocation
.
Parameters
A map of options to pass to the method.
- dragLocation - Point
- The location to check for a valid port owner.
Returns
- ↪IModelItem?
- A port owner or
null
if no valid port owner was found at the drop location.
Overrides
getNewPortLocationModelParameter
(owner: IPortOwner, draggedPort: IPort, dragLocation: Point) : IPortLocationModelParameterDetermines the IPortLocationModelParameter the port should have if it was dropped at dragLocation
over owner
.
Remarks
If useLocationForParameter is false
(the default), this implementation returns the locationParameter of the draggedPort
if it is applicable to owner
. If it is not applicable, the method returns null
. In this case, the dragLocation
is ignored.
If useLocationForParameter is true
, this implementation will use the model of the draggedPort
(if compatible with owner
) to determine the parameter that corresponds best to the current dragLocation
.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The port owner where the port would be created. May be
null
. - draggedPort - IPort
- The port that is currently dragged.
- dragLocation - Point
- The current drag location.
Returns
Initializes the drop target.
Defined in
Initializes the item preview.
Remarks
Defined in
Initializes the snapping context.
Installs this mode into the given canvas.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- the context to install this mode into
- controller - ConcurrencyController
- The controller for this mode.
See Also
Implements
Default backing method for isValidPortOwnerPredicate
Remarks
owner
and draggedPort
.Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The port owner where the port would be created. May be
null
. - draggedPort - IPort
- The port that is currently dragged.
Returns
- ↪boolean
true
iffowner
can be used to drop a port.
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.
Defined in
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.
Defined in
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.
Overrides
Called once a drag has been dropped on the canvas.
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Overrides
Called once a drag has entered the canvas.
Remarks
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Overrides
Called whenever a drag is over the canvas.
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Overrides
Called once a drag has left the canvas.
Parameters
A map of options to pass to the method.
- evt - InputModeEventArgs
- The event argument that contains context information.
Overrides
Called whenever a new item is created.
Parameters
A map of options to pass to the method.
- evt - InputModeItemEventArgs<IPort>
- The InputModeItemEventArgs<TModelItem> containing the new item.
Defined in
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.
Defined in
Subclasses shall fill the specified graph that is used to preview the dragged item.
Parameters
A map of options to pass to the method.
- previewGraph - IGraph
- The preview graph to fill.
Overrides
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.
Parameters
A map of options to pass to the method.
- location - Point
- The current location of the pointer in world coordinates.
Overrides
Overridden to only return true
if this instance does not currently have the input mutex.
Uninstalls this mode from the canvas.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- the context
Implements
Calls getDropTarget for snappedPointerPosition and sets the returned item as dropTarget.
Remarks
Parameters
A map of options to pass to the method.
- dragLocation - Point
- The location to update the drop target for.
Defined in
Subclasses shall update the previewGraph so the dragged item is displayed at the specified dragLocation
.
Parameters
A map of options to pass to the method.
Overrides
Events
Occurs when a drag operation is dropped onto the CanvasComponent into which this instance is installed.
Remarks
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.
Defined in
Occurs when a drag operation enters the CanvasComponent into which this instance is installed.
Remarks
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.
Defined in
Occurs when a drag operation leaves the CanvasComponent into which this instance is installed.
Remarks
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.
Defined in
Occurs when a drag operation drags over the CanvasComponent into which this instance is installed.
Remarks
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.
Defined in
Occurs when a new item gets created by this input mode.
Defined in
Constants
The transfer type to which the PortDropInputMode and its startDrag method is configured by default.
Static Methods
startDrag
(dragSource: HTMLElement | SVGElement, port: IPort, dragDropEffects?: DragDropEffects, useCssCursors?: boolean, dragPreview?: HTMLElement | SVGElement) : DragSourceStarts a drag and drop operation for a IPort.
Remarks
This method creates a DragSource, and then invokes startDrag with a DragDropItem that contains the port
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
Parameters
A map of options to pass to the method.
- dragSource - HTMLElement | SVGElement
- The source of the drag operation.
- port - IPort
- The port 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 - HTMLElement | SVGElement
- 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.
Returns
- ↪DragSource
- The new DragSource instance.