Skip to content

feat: reactive ui elements handle picking events - #729

Open
makspll wants to merge 4 commits into
agent/reactive-ui-contextfrom
agent/reactive-ui-events
Open

makspll wants to merge 4 commits into
agent/reactive-ui-contextfrom
agent/reactive-ui-events

Conversation

@makspll

@makspll makspll commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Elements handle bevy_picking's pointer events, instead of polling the deprecated Interaction component.

ui.node({
    on_click = function(event) print(event.button, event.x, event.y) end,
    on_press = ..., on_release = ...,
    on_pointer_enter = ..., on_pointer_leave = ...,
    on_hover = function(over) ... end,          -- both of the above, given whether the pointer is over the element
    on_drag = function(event) print(event.delta_x, event.delta_y) end,
    on_scroll = ...,
})
  • one observer per pointer event (events.rs) queues the handler of the entity the event is at. Handlers run in the next flush, in their script's context, as before
  • the innermost element with a handler for an event gets it, the event does not bubble further. An element without one lets it through to its ancestors
  • handlers are given the event after their dependencies and (in a row template) the row's item: { x, y, button, count, delta_x, delta_y } as the event has them
  • ui.interact(entity, "click") does what a pointer event on the element would, for tests and for driving a ui without a pointer (it takes the event names now: "press" is on_press)
  • elements with handlers no longer need an extra component, picking finds nodes itself

Rune checks argument counts, so its handlers declare the event: |selected, name, _event| ...

Not covered by a test: the observers themselves (the tests go through ui.interact), there is no pointer in the headless test app.

Stacked on #728.

@semanticdiff-com

semanticdiff-com Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

@makspll
makspll added this pull request to stack #718 November 13, 2026 13:19
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

ProjectBevy Scripting
Branchagent/reactive-ui-events
Testbedlinux-gha

⚠️ WARNING: Truncated view!

The full continuous benchmarking report exceeds the maximum length allowed on this platform.

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

ProjectBevy Scripting
Branchagent/reactive-ui-events
Testbedlinux-gha

⚠️ WARNING: Truncated view!

The full continuous benchmarking report exceeds the maximum length allowed on this platform.

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

🐰 View full continuous benchmarking report in Bencher

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant