bevy/release-content/release-notes
Alice Cecile b7d2cb8547
Provide access to the original target of entity-events in observers (#19663)
# Objective

Getting access to the original target of an entity-event is really
helpful when working with bubbled / propagated events.

`bevy_picking` special-cases this, but users have requested this for all
sorts of bubbled events.

The existing naming convention was also very confusing. Fixes
https://github.com/bevyengine/bevy/issues/17112, but also see #18982.

## Solution

1. Rename `ObserverTrigger::target` -> `current_target`.
1. Store `original_target: Option<Entity>` in `ObserverTrigger`.
1. Wire it up so this field gets set correctly.
1. Remove the `target` field on the `Pointer` events from
`bevy_picking`.

Closes https://github.com/bevyengine/bevy/pull/18710, which attempted
the same thing. Thanks @emfax!

## Testing

I've modified an existing test to check that the entities returned
during event bubbling / propagation are correct.

## Notes to reviewers

It's a little weird / sad that you can no longer access this infromation
via the buffered events for `Pointer`. That said, you already couldn't
access any bubbled target. We should probably remove the `BufferedEvent`
form of `Pointer` to reduce confusion and overhead, but I didn't want to
do so here.

Observer events can be trivially converted into buffered events (write
an observer with an EventWriter), and I suspect that that is the better
migration if you want the controllable timing or performance
characteristics of buffered events for your specific use case.

## Future work

It would be nice to not store this data at all (and not expose any
methods) if propagation was disabled. That involves more trait
shuffling, and I don't think we should do it here for reviewability.

---------

Co-authored-by: Joona Aalto <jondolf.dev@gmail.com>
2025-06-15 20:53:25 +00:00
..
.gitkeep Add basic release content tagging workflow (#18568) 2025-03-27 17:46:39 +00:00
bevy_solari.md Initial raytraced lighting progress (bevy_solari) (#19058) 2025-06-12 21:26:10 +00:00
entity-spawn-ticks.md Fix EntityMeta.spawned_or_despawned unsoundness (#19350) 2025-05-27 22:45:07 +00:00
event_split.md Event Split: Event, EntityEvent, and BufferedEvent (#19647) 2025-06-15 16:46:34 +00:00
headless-widgets.md Core slider (#19584) 2025-06-15 00:53:31 +00:00
hot_patching.md Hot patching systems with subsecond (#19309) 2025-06-03 21:12:38 +00:00
log-diagnostics-state-public.md Expose LogDiagnosticsState (#19323) 2025-05-23 20:56:36 +00:00
observer_overhaul.md Provide access to the original target of entity-events in observers (#19663) 2025-06-15 20:53:25 +00:00
specialized_ui_transform.md Specialized UI transform (#16615) 2025-06-09 19:05:49 +00:00
system_set_naming_convention.md Adopt consistent FooSystems naming convention for system sets (#18900) 2025-05-06 15:18:03 +00:00
text-background-colors.md Text background colors (#18892) 2025-05-04 08:18:46 +00:00
ui_gradients.md Rename Position to UiPosition in bevy_ui (#19422) 2025-05-29 14:52:44 +00:00
viewport-node.md Add a viewport UI widget (#17253) 2025-05-05 22:57:37 +00:00