Default Edge Overwrite
DefaultEdgeOptions gives every edge the user draws a house style - here an animated, round-cornered smooth step with a closed arrow, a thicker indigo stroke, a wider hit area and ends that stay put. The edge already in the list keeps the plain defaults: the options only reach new edges.
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 dot under Drag from my handle to the dot on top of or here: the new edge arrives animated, smooth-stepped with round corners, indigo, thicker and with a filled arrowhead.
- Compare it with the grey edge into to here, which was in the list from the start and keeps the built-in look.
- Click near the new edge rather than on it: its wider hit area still selects it.
- With the new edge selected no end dots appear, so its ends cannot be dragged to other handles; select the grey edge and its two dots are there to drag.
- Press Backspace or Delete to remove a selected edge and draw it again.
How it works
DefaultEdgeOptionstakes aBlowDefaultEdgeOptions, applied to each edge the moment the user creates it; edges put in theEdgeslist by code are left alone.Type = SmoothStepsets the path; left null it falls back to the canvas'sDefaultEdgeType.PathOptions(here aBorderRadiusof 16 instead of 5) is cloned into each new edge, so retuning one edge never retunes the others.Animated(off by default) runs the marching dash;MarkerType = ArrowClosedfills the arrowhead thatMarkerEnd(on by default) draws.StrokeandStrokeWidthreplace the theme colour and the 1.5 width;InteractionWidthwidens the invisible hit path from 14 to 24 screen pixels.Reconnectable = false(true by default) keeps new edges' ends where they were drawn.Style,ClassandMarkerStartare there too.