Custom Node
A 'text updater' node drawn by a NodeTemplate: its own markup, a text field bound to the node's Data, and handles placed by hand - one target and two named sources. Each output node shows what reaches it along the edges: the text from handle a, its length from handle b.
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
- Type in the field: the output under handle a mirrors the text, and the one under handle b counts its characters. Backspace edits the text rather than deleting the node.
- Drag the node by anything but the field: pressing or selecting in the field never moves it.
- Click an edge to select it, then drag the dot at its lower end onto the other output - or press Delete: each output shows what now reaches it, or (not connected).
- Drag from handle a or b to an output to wire it up again.
How it works
NodeTemplaterenders the content of every node. It switches onnode.Typeand hands every other type back to the built-in renderer with<BlowDefaultNode Node="node" />. With a template, the add-ons go in an explicit<ChildContent>.Datacarries the node's payload, aTextDatahere: the field writes to it, and the page works the outputs'Labelout again.- Each
BlowHandleis placed by hand with itsTypeandPosition. The two source handles need anIdeach, which edges name throughSourceHandle;Style="left: 25%"moves a handle along its side. - The field carries the
nodragclass (the canvas'sNoDragClass), so a press on it neither selects nor drags the node; graph keys such as Backspace are ignored while focus is in a text field. EdgesChangedis raised after the canvas changes the edge list - a connect, a reconnect or a delete - and the page reads the outputs off the edges again.- The template renders inside the node element, so it keeps the node's padding, border and background;
Width = 170gives the field room.