Description
What problem does this solve or what need does it fill?
Typically, when users click on a UI element (including in game units), we don't want to also handle that click in the rest of the world.
The same pattern is observed when typing into a chat box, where the keyboard inputs are stolen.
Right now, the default behavior is to pass all events through.
What solution would you like?
A few solutions immediately come to mind:
- Centralize this input stream splitting technique into a single standard mega-system that can be customized using function pointers.
- Assign ownership of input stream events by storing some form of owner (entities? labels?) on the input events as an optional field.
- Assign ownership of input events using entity-specific events (Suggestion: Entity Events #2070, Per entity Events #2116).
- Add a
split
method toResMut<Events<T>>
, which returns two iterators of events based on whether the supplied predicate is true. This doesn't make the chaos any better, but does improve ergonomics.
What alternative(s) have you considered?
Consume events in one-off systems using ResMut<Events<Input<T>>>
.
This was the approach taken in vladbat00/bevy_egui#50, specifically vladbat00/bevy_egui@53c1773#diff-420f4e08a25299e0e1fb09f4757e1d5d027a2278f37030c09ab9c06786cfa52eR283.
However this is not a particularly principle or discoverable approach, and risks serious chaos as input events are silently eaten according to decentralized rules based on system ordering.
Additional context
Initially discussed on Discord. Led to #3569. Related reddit post with proposed workarounds.
Activity