macro_rules! wire_selection {
(@click $window:expr, $on:ident, $target:expr, [$($model:expr),*]) => { ... };
(@clear $window:expr, [$($model:expr),*]) => { ... };
(@box $window:expr, $setup:expr, $links:expr, [$(($model:expr, $hits:expr)),*]) => { ... };
($window:expr, $setup:expr, $nodes:expr) => { ... };
($window:expr, $setup:expr, $nodes:expr, $links:expr) => { ... };
($window:expr, $setup:expr, $nodes:expr, $links:expr, $groups:expr) => { ... };
}Expand description
Wire the editor’s selection intents, using your model rows as the store.
The editor holds no selection state: it reports gestures (node-selected,
select-link, selection-cleared, box-selection-committed) and renders
whatever selected flag it finds on the rows. This macro closes that loop
without introducing a second copy of the selection — each gesture reads the
current set back out of the rows, resolves it through
resolve_click / resolve_box, and projects the result in. There is
nothing to keep in sync, because there is only ever one record of what is
selected.
Rows need an id and a selected field.
Three arms: node selection alone, nodes and links together, or nodes,
links and groups. Applications with several node models or their own
gesture semantics wire the callbacks by hand out of the selection
module — see the advanced example.
§Generated-UI integration
This fragment assumes the generated callbacks and models from the compiled quick start.
wire_node_editor!(window, setup);
wire_selection!(window, setup, nodes);
// …or, with selectable links:
wire_selection!(window, setup, nodes, links);
// …or, with groups as well (the window exposes `group-selected`):
wire_selection!(window, setup, nodes, links, groups);