documentationfor yFiles for HTML 3.0.0.3

CreateEdgeInputMode

An IInputMode for interactively creating edges between nodes and edges in an IGraph displayed in a CanvasComponent or GraphComponent.

Inheritance Hierarchy
CreateEdgeInputMode
Implemented Interfaces

Remarks

This class provides a factory callback that the final edge creation will be delegated to. The styling of the newly created edge can be customized via the edgeDefaults. Defaults can be automatically adjusted in response to the various events that will be triggered by this instance during the edge creation.

Use the previewGraph property to modify the appearance of the preview edge. This class uses IPortCandidateProvider instances found in the ILookup of the nodes in the graph to display port candidates and to finally create the edges.

The CreateEdgeInputMode provides a well-defined event lifecycle to track the progression of the edge creation:

  • gesture-starting – Occurs when the edge creation gesture is initiated. This happens before the edge becomes visible and marks the beginning of the interaction sequence.
  • gesture-started – Occurs immediately after gesture-starting, indicating that the gesture has been fully initialized and is now in progress. This event precedes any visible feedback or edge creation operations.
  • edge-creation-started – Occurs when the creation of an edge visibly begins. This happens when the cursor moves outside the source node during the gesture. At this point, the target port candidate becomes relevant.
  • gesture-canceling – Occurs when the edge creation gesture is about to be canceled. This event is always followed by gesture-canceled.
  • gesture-canceled – Occurs when the gesture has been canceled. No edge will be created, and the gesture sequence ends.
  • gesture-finishing – Occurs when the gesture is about to be successfully completed. This event allows the target port candidate to be updated one last time before finalization.
  • edge-created – Occurs after an edge has been successfully created as a result of the interaction.
  • gesture-finished – Occurs when the edge creation gesture has successfully completed and all operations are finalized.

Additionally, the following auxiliary events provide specific feedback during the gesture:

  • moving and moved – These events occur at the start and end of every drag or move action during the gesture.
  • edge-direction-reversed – Occurs if the direction of the edge creation is reversed during the gesture.

This event sequence ensures symmetry between the initialization and finalization of gestures, and provides fine-grained control for handling cancellations and completions.

This mode is exclusive by default.

Examples

Typically the CreateEdgeInputMode is installed as child mode of a GraphEditorInputMode and can be retrieved from the createEdgeInputMode property.
Getting the CreateEdgeInputMode from its parent input mode
const createEdgeInputMode = mode.createEdgeInputMode
The following example shows how to configure touch gestures without long press.
Configure touch gestures without long press
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

Related Reading in the Developer's Guide

An overview of this input mode is given in the section Creating Edges. Additionally, customization of edge creation is discussed in section Customizing User Interaction: Creating Edges .

Type Details

yFiles module
view

Constructors

Properties

Methods

Events