Custom Nodes
A NodeTemplate renders your own markup inside each node: here a colour node with a working colour
picker and two labelled source handles, while every other node falls back to the built-in look through
BlowDefaultNode.
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
- Click the swatch on Crimson or Emerald and pick another colour: the swatch and the hex code under the name follow as you choose.
- Hover the two handles on the right of a colour node: the tooltips name them Output A and Output B.
- Drag from either handle to another node to connect it; each edge remembers which of the two it leaves from.
- Drag a colour node by its name to move it - a press on the swatch opens the picker instead.
- Tab to Crimson and press C: a connection starts from Output A and is announced by that name, and C again switches it to Output B. Keep pressing Tab until Palette has focus, then Enter connects and Escape gives up.
How it works
NodeTemplateis aRenderFragment<BlowNode>that replaces the content of every node; it switches onnode.Typeand reads its own payload fromnode.Data.- The template is part of the page, so
@bindon the picker writes straight into the node'sColorData, and the re-render that follows redraws the node. - The picker carries the
nodragclass (the canvas'sNoDragClass), so pressing it neither selects nor drags the node. BlowHandlegoes anywhere in the template:TypeandPositionsay what and on which side,Style="top:35%"moves it along that side, and anIdtells handles of the same type apart. The starting edges pick theirs withSourceHandle = "a"and"b".Portson the node model declares the two outputs asBlowPorts; a port'sLabelbecomes its handle's tooltip and the name a screen reader hears when connecting from the keyboard.- Every other type is handed back to
BlowDefaultNode, which draws the built-in content; Mixer'sTargetPositionandSourcePositionput its handles on the left and right. - The template renders inside the node's own chrome - padding, border, background - and
Width = 180fixes the colour nodes' width. With a template set, the add-ons go in an explicit<ChildContent>.