Handle Rules
Rules can live on the handle they belong to instead of in one canvas-wide predicate: a BlowHandle can carry its own IsValidConnection and OnConnect, a DataType and a MaxConnections, and can refuse to start or to accept connections at all. Use it when each port of a node template has rules of its own.
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 Producer's number output: the Adder's input turns green and the Formatter's red. From the text output it is the other way round. Release on the green one to connect; the line beside the toolbar says which input announced the arrival.
- Release on a red input: nothing connects, and the line says why - the Adder refuses by its rule, the Formatter by its data type.
- Drag backwards from the Adder's input to the text output: refused too, because the rule of the handle a drag starts at gets a say as well as the one it ends on.
- With Adder takes one wire ticked, connect the number output to the Adder, then try again: the Adder's input is full, shows 1/1 - full, and no longer starts or accepts connections until you delete the edge (select it, then Delete) or untick the box.
- Change Formatter's input: with IsConnectableStart = false pressing it starts nothing, but a drag still ends there; with IsConnectableEnd = false nothing can be dropped on it, though a drag can still start from it; IsConnectable = false does neither. Reset clears the edges.
How it works
IsValidConnectionon aBlowHandleis aFunc<BlowConnection, bool>like the canvas's. The rules of both handles a connection would join are asked, together with the canvas's, and a refusal isRejectedByRule.DataTypedeclares what a handle carries; incompatible types are refused asIncompatibleTypes, and the type is rendered asdata-port-type, which this page's stylesheet colours by. It overrides theDataTypeof a port declared inBlowNode.Ports- see Typed Ports for the model side.MaxConnections(null for no limit) caps a handle's edges. At the limit the handle neither starts nor accepts connections and is not drawn as connectable; a drop isTargetFullorSourceFull. The canvas'sCountConnectionsandIsHandleAtLimitgive the Adder's 1/1 - full.IsConnectableStartandIsConnectableEnd(both true by default) switch off starting a connection at the handle, or ending one on it;IsConnectableswitches off both. A drop on a handle that takes none is refused asNotConnectable.OnConnecton a handle is raised when the user makes a new connection at it - by dragging, by clicks or from the keyboard, though not when an existing edge is reconnected to it.OnConnectEndon the canvas reports the refusals, with theirRejection.