pub fn Canvas(_: CanvasProps) -> ElementExpand description
The pannable/zoomable surface every flow is drawn on.
Owns the FlowCore context, the container geometry, and the pane
gestures: pan (drag or scroll), zoom (scroll or pinch), pane clicks, and
the in-flight connection state machine that crate::Handles feed.
Draws nothing itself: Flow passes its node/edge layers through the
world slot, and an application using Canvas directly renders its own
content there (in flow coordinates) and overlays as children (in screen
coordinates).
An application-level gesture that starts on content inside the canvas can
take the pointer away from the pane with FlowCore::claim_pointer; the
pane then neither pans nor reports a pane click for that press.
§Props
For details, see the props struct definition.
min_zoom:f64max_zoom:f64pan_on_drag:boolPan the canvas by dragging empty space.
zoom_on_scroll:boolZoom with the mouse wheel / trackpad.
pan_on_scroll:boolScrolling pans instead of zooming (shift swaps the axis, ctrl/meta — a trackpad pinch included — zooms about the pointer). Takes precedence over
zoom_on_scroll.nodes_draggable:boolMaster switch for node dragging (read by
Flow’s node layer).drag_threshold:f64How far (screen px) a press on a node must travel before it moves the node, so a sloppy click never nudges one.
connection_radius:f64Snap radius (screen px) for completing a connection near a handle.
fit_view_padding:f64id:Option<String>idattribute for the root element, so applications can find, focus, measure, or capture pointers to the canvas by id.aria_label:StringAccessible name for the canvas.
class:Option<String>Extra classes for the root element.
on_pane_press:Option<Callback<Event<PointerData>>>A primary press reaching the pane, before the pane decides to pan: the hook for application-level pane gestures (marquee selection, pulling a connection from a node border…). A handler that starts one claims the pointer with
FlowCore::claim_pointer; the pane then leaves this press alone.edges:Option<Signal<Vec<Edge>>>The caller’s edges, when it has any (the
Flowlayers and the default connect behavior read and write these through the core).geoms:Option<Memo<Vec<NodeGeom>>>Node geometry snapshot, when the caller renders nodes (
Flowpasses its memo; standalone canvases leave it empty).deselect_nodes:Option<Callback<()>>Type-erased “deselect all nodes” for pane clicks and edge selection, provided by
Flowwhich knows the node type.on_connect:Option<EventHandler<Connection>>Called when the user completes a connection between two handles. When absent, the edge is added to
edgesautomatically.on_connect_start:Option<EventHandler<HandleKey>>A connection drag has left a handle (started, not completed).
on_connect_end:Option<EventHandler<ConnectEnd>>A connection drag ended — wherever it ended.
connectionisNonewhen the release was over nothing, and the point says where: the hook for “drop on empty canvas to create the node there”.is_valid_connection:Option<Callback<Connection,bool>>The application’s say over which connections may complete. A target that fails is never offered as a snap and never completes.
on_node_drag_start:Option<EventHandler<Vec<Id>>>A node drag actually began (the press travelled past
drag_threshold), with the ids being dragged: the moment to snapshot for undo.on_node_drag_stop:Option<EventHandler<Vec<Id>>>A node drag ended, with the ids that were dragged. Positions are already final in the node list: the moment to snap, settle, persist.
on_pane_click:Option<EventHandler<Point>>Click on empty canvas; the point is in flow coordinates. Fires only when the press neither travelled nor was claimed by content.
on_pane_double_click:Option<EventHandler<Point>>Double-click on the canvas; the point is in flow coordinates. The pane cannot tell content from paper here — an application that must can hit-test the client point itself before acting.
on_canvas_key_down:Option<Callback<Event<KeyboardData>>>Keyboard events reaching the canvas root, after the canvas’s own Escape handling.
Flowwires Delete/Backspace through this.on_drag_move:Option<Callback<Point>>Pointer moves while a node drag is in flight, in flow coordinates.
Flowapplies the drag to its typed node list through this.world:Option<Element>Content drawn inside the viewport transform, in flow coordinates.
children:ElementOverlays drawn over the canvas in screen coordinates ([
Background], [Controls], [MiniMap], or your own — they can call [use_flow]).[
Background]: crate::Background [Controls]: crate::Controls [MiniMap]: crate::MiniMap [use_flow]: crate::use_flow