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.
Press Tab to move between the nodes and edges of the diagram.
Press Enter or Space to select it, Shift with Enter to add it to the selection, the arrow keys to move the selected nodes, Delete to remove them and Escape to clear the selection. Press C to start a connection from it.
Press Enter or Space to select it, Delete to remove it and Escape to clear the selection. Press C to move its end to another node.
bit BlowTry 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
OnConnectEndis raised once for every connection gesture, whether or not it connected, with aBlowConnectEndInfo.- A node is added only when
IsValidis false (nothing connected),IsDroppedis true (released after a real drag, not a click, Escape or a cancelled pointer),IsReconnectis false (not an existing edge's end), andRejectionisNone- it was let go on empty space rather than on, or withinConnectionRadiusof, a handle that refused it. FlowPositionis the release point in flow coordinates; the new node gets an explicitWidthandHeight(BlowNode.DefaultWidthbyDefaultHeight) so the arithmetic puts its handle exactly there.Startnames 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.