Skip to content

Add advice on best practices for handling event propagation#23728

Merged
alice-i-cecile merged 2 commits intobevyengine:mainfrom
alice-i-cecile:stop-bubbling
Apr 9, 2026
Merged

Add advice on best practices for handling event propagation#23728
alice-i-cecile merged 2 commits intobevyengine:mainfrom
alice-i-cecile:stop-bubbling

Conversation

@alice-i-cecile
Copy link
Copy Markdown
Member

Objective

@viridia mentioned this advice off-hand.

It was good advice (and used in our UI crates), but was never written down.

Solution

Write down and cross-link the advice.

@alice-i-cecile alice-i-cecile requested review from kfc35 and viridia April 8, 2026 22:43
@alice-i-cecile alice-i-cecile added C-Docs An addition or correction to our documentation A-UI Graphical user interfaces, styles, layouts, and widgets S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 8, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in UI Apr 8, 2026
@viridia
Copy link
Copy Markdown
Contributor

viridia commented Apr 8, 2026

One more nuance: if a handler, handling an event, wants to trigger additional behaviors further up the hierarchy, the best practice is to define a new event type for this, rather than re-using the event.

@kfc35 kfc35 added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 8, 2026
@viridia
Copy link
Copy Markdown
Contributor

viridia commented Apr 8, 2026

This means that in a complex, multi-layered hierarchy comprised of nested, reusable modules, the events will evolve and transmute as they travel upwards, starting out as low-level machine signals (like "key press") and eventually becoming high-level, semantic, meaning-laden events such as "save document" or "pause animation".

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Apr 9, 2026
@alice-i-cecile alice-i-cecile added the A-ECS Entities, components, systems, and events label Apr 9, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in ECS Apr 9, 2026
Merged via the queue into bevyengine:main with commit b4d4adc Apr 9, 2026
49 checks passed
@github-project-automation github-project-automation bot moved this from Needs SME Triage to Done in UI Apr 9, 2026
@github-project-automation github-project-automation bot moved this from Needs SME Triage to Done in ECS Apr 9, 2026
viridia pushed a commit to viridia/bevy that referenced this pull request Apr 10, 2026
…ne#23728)

# Objective

@viridia mentioned this advice off-hand.

It was good advice (and used in our UI crates), but was never written
down.

## Solution

Write down and cross-link the advice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events A-UI Graphical user interfaces, styles, layouts, and widgets C-Docs An addition or correction to our documentation S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants