Repository navigation
Identified nodes return a NodeHandle: .on_click / .on_response / .draw replace the positional draw closure (#66) - #67
Merged
Merged
Conversation
…#66) div_id, span and icon (and the crate-internal leaf, div_id_with and leaf_with) no longer take a positional draw closure; most call sites passed `none`. The node is still added immediately and the call returns a NodeHandle that borrows the builder for the statement. `.draw`, `.on_click` and `.on_response` attach behaviour to the node; dropping the handle attaches nothing, so it is not must_use. Handlers compose: each call wraps the node's existing draw closure, so `.on_click(..).on_response(..)` runs both in call order in the node's own Ui, instead of a debug panic on the second call. A node's Sense comes from its Tw (sensing, grouping, variants), never from the presence of a draw closure, so the build-error rules are unchanged. A node without a handler now has no draw slot at all, so it no longer opens a draw-time Ui. `leaf` keeps its positional measure and returns the same handle; the owned widgets use `.draw(..)` on it. `widget` keeps its positional draw because the draw is its point and receives the widget back. Breaking API change: `bullseye::none` is removed, div_id/span/icon lose their draw argument and return NodeHandle, and closures that were `|b| b.span(..)` now need a block. NodeHandle<A> needs A: 'static. Call sites outside src follow in the next commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Mechanical migration of examples, tests, doc tests and docs/design.md to the NodeHandle API: `none` arguments dropped, draw closures moved to `.draw(..)`, `common::on_click(..)` adapters to `.on_click(..)`, and expression-bodied closures given a block. examples/common::on_click is removed. Goldens are unchanged. layout::identified_nodes_are_found_by_id_and_path now attaches a draw explicitly, because a node without one no longer reports has_draw. New tests in tests/it/interaction.rs cover a handlerless div_id, on_click via the real pointer path, on_response hover, draw's content-rect Ui, and handler composition order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
The mechanical migration turned every inline draw closure into a literal
`.draw(..)`. Where the closure is only `if node_response().clicked() { X }`
it is now `.on_click(|app| X)`; where it only reads the response (the
resize handles, the GitHub link) it is `.on_response(|app, response| ..)`
and reaches the context through `response.ctx`. `.draw` stays where the
closure really uses the Ui: adds widgets, paints, or reads its rect, id,
opacity or clip.
NodeHandle::on_click no longer calls request_repaint: egui already repaints
after every input frame (#63), so it was redundant. No behaviour change;
all goldens are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #66. Breaking change (undeployed): every identified-node builder loses its positional draw-closure argument, and
bullseye::noneis removed.Shape
Ui.on_clickandon_responseare thin wrappers overdraw, with the same names as the owned widget chains (API ergonomics: readable class syntax, symmetric widget calls, optional keys #41).Tw, never from the presence of a closure, and every interaction test passes unchanged.widget()keeps its positional draw: its closure receives the stock widget, so one without a draw makes no sense. The crate-internalleafreturns the handle.custom(..)remains the public measure+ui route.Before / after
Migration
.on_clickand 3 became.on_response..drawremains only where the closure really uses theUi(egui widgets,ui.is_enabled()for widget info, style, data, rect probes).common::on_clickadapter.|b| b.span(..)) needed braces, because they now return a handle.Behaviour changes
Ui. ThatUidid nothing, and no golden or interaction test changed.on_clickno longer callsrequest_repaint()(the old adapter did). A handler's state change isn't shown until the next input event (no repaint requested) #63 established that egui already repaints after every input frame.layout::identified_nodes_are_found_by_id_and_pathpreviously assertedhas_draw()on a span whose draw was onlynone. It now attaches.draw(..)explicitly and also asserts that a span with no handler has no draw.Tests
New, in
tests/it/interaction.rs:div_idwith no handler;on_clickfires once per click through the real pointer path;on_responsesees hover;drawgets the content-rectUi;All 71 goldens are unchanged.
cargo xtask ciis green.There's no UI change, so there's nothing to try. The reference shell migrates after the tag.
🤖 Generated with Claude Code
https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up