Skip to content

Add Node on Edge Drop

Let go of a connection on empty canvas and a new node appears there, already connected. OnConnectEnd reports how every connection gesture ended - where, from which handle, and whether it connected - which is all it takes to grow a graph by dragging out of it.

Drag a connection out onto empty canvas.
Drag from my handle
bit Blow

Try it

  • Drag from the handle under "Drag from my handle" and release on empty canvas: a new node appears with its top handle where you let go, fed by the node you dragged from.
  • Drag from a new node's top (target) handle instead: the node that appears sits above the drop point and feeds the one you started from.
  • Release on another node's handle and it simply connects; release on or near a handle that refuses the connection - two top handles, say - and no node is added either.
  • A click on a handle, Escape during a drag, and letting go of a selected edge's end on empty canvas add nothing. The line beside the toolbar says how each gesture ended; Reset starts over.

How it works

  • OnConnectEnd is raised once for every connection gesture, whether or not it connected, with a BlowConnectEndInfo.
  • A node is added only when IsValid is false (nothing connected), IsDropped is true (released after a real drag, not a click, Escape or a cancelled pointer), IsReconnect is false (not an existing edge's end), and Rejection is None - it was let go on empty space rather than on, or within ConnectionRadius of, a handle that refused it.
  • FlowPosition is the release point in flow coordinates; the new node gets an explicit Width and Height (BlowNode.DefaultWidth by DefaultHeight) so the arithmetic puts its handle exactly there.
  • Start names the handle the drag began at - NodeId, HandleId, HandleType - which decides whether the new edge leaves the start node or enters it.
  • The page adds the node and the edge to its own lists, which the canvas draws from, and Refresh(remeasure: true) has it measure the new node straight away.
An unhandled error has occurred. Reload 🗙