Selection Gestures
Everything about making and using a selection: which key opens a selection box and which one adds to a selection, what the box picks up, and the events for the box, for dragging several nodes as one (OnSelectionDragStart, OnSelectionDrag, OnSelectionDragStop) and for right-clicking a whole selection (OnSelectionContextMenu).
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
- Shift+drag across the background to draw a selection box round a few nodes: the log shows the box starting and ending, and what it selected.
- Switch Box picks to Full and draw again: only nodes entirely inside the box are picked, not every node it touches. Untick Box selects edges and the box leaves the edges between the picked nodes unselected.
- Drag one of the selected nodes: they all move together, and the log shows one selection drag - with how many
OnSelectionDragmoves it took - next to the drag of the node you grabbed. Drag a node that is not selected: only it moves, and only a node drag is logged. - Right-click one of several selected nodes: the log shows the node's menu event and then the whole selection's. Right-click a node on its own and only the node's event comes. No browser menu opens over a node.
- Change Selection key to Alt or Control and that key opens the box instead; with none, only a plain drag with Selection on plain drag ticked draws one.
- Hold the Multi-select key and click nodes to add them one at a time; held while drawing a box, it adds the box's catch to the selection rather than replacing it.
- Tick Selection on plain drag: now a drag on the background draws a box, and holding the Pan key (Space) turns it back into a pan. Pick none and the background can no longer be dragged to pan - the wheel and the control bar still move the view.
How it works
SelectionKey(BlowModifierKey.Shift) held turns a drag on the pane into a selection box;nullleaves boxes toSelectionOnDrag(false), which makes every plain drag draw one.PanActivationKey(" ", Space) held turns any drag on the pane into a pan, even withSelectionOnDrag; it is aKeyboardEvent.keyname, andnulldisables it.MultiSelectionKey(BlowModifierKey.Shift) adds a clicked node or edge to the selection, and makes a box add to it. Both keys default to Shift, so Shift+drag draws a box that adds.SelectionMode(BlowSelectionMode.Partial) picks every node the box touches;Fullonly those it encloses.SelectEdgesOnSelectionBox(true) also picks the edges whose two nodes the box picked.OnSelectionStartandOnSelectionEndbracket a box with thePointerEventArgsof the press and the release; by the end the selection is final.OnNodeDragStart,OnNodeDragandOnNodeDragStopreport the node grabbed, as aBlowNode. When more than one node moves,OnSelectionDragStart,OnSelectionDragandOnSelectionDragStopreport all of them as aBlowSelectionMouseEvent(Nodes,Event), so the group can be treated as one edit. The start events come at the press, so a stop with no moves since was a click.OnNodeContextMenu(aBlowNodeMouseEvent) reports the node right-clicked; when it is one of several selected,OnSelectionContextMenufollows with the whole selection. Handling either suppresses the browser's menu over nodes.