Skip to content

Identified nodes: drop the positional draw closure; attach handlers with .on_click / .draw on a returned handle #66

Closed

Description

@samitbasu

Decided by the user: identified nodes lose the positional draw-closure argument. Today it's div_id(key, tw, draw, body), span(key, tw, text, draw), icon(key, tw, icon, draw) and so on, and most call sites pass bullseye::none (47 uses). Examples wrap clicks in a common::on_click adapter. Those nodes are identified for identity (animation, scope, focus), not for handling anything.

Shape

The node is added immediately, as today, so the common case needs no terminating call. The call returns a small handle that can attach behaviour to the node just added:

b.div_id(key, row_style(&t), |b| { … });                          // common case: nothing to attach
b.span("up", tw, "Up").on_click(move |s| s.shift(key, Up));       // click handler
b.div_id(key, tw, |b| { … }).draw(|app, ui| { … });               // escape hatch: own Ui at draw time
b.span(k, tw, "x").on_response(|app, response| { … });            // hover etc., like the widgets
  • The handle borrows the builder mutably for the statement and fills the node's draw slot when a method is called. It is not #[must_use]: dropping it means "no handler".
  • At most one draw closure per node. Calling .draw/.on_click/.on_response twice is a debug panic; or they compose. Decide in the PR and justify the choice.
  • .on_click(|app|) and .on_response(|app, &Response|) share their names and signatures with the owned widgets' chains (API ergonomics: readable class syntax, symmetric widget calls, optional keys #41), so the vocabulary is the same everywhere.
  • bullseye::none and examples/common::on_click are removed.
  • Applies to every identified-node builder: div_id, span, icon, image, leaf and the rest. Check whether leaf's measure argument should become a handle method too, or whether custom(..) already covers it.

Constraints

Activity

  1. added a commit that references this issue on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions