bevy_eventlistener icon indicating copy to clipboard operation
bevy_eventlistener copied to clipboard

Add the ability to have multiple callbacks in a single listener

Open alice-i-cecile opened this issue 2 years ago • 3 comments

This feature is necessary because there's currently no way to have more than one of a callback of a single type on an entity.

This is usually just a papercut, but it is required in bevy_mod_picking, in order to merge on_click / on_drag etc into a single callback.

In turn, we want to do that in order to handle the ordering of input events correctly„ using https://github.com/bevyengine/bevy/pull/12100

alice-i-cecile avatar Mar 06 '24 20:03 alice-i-cecile

This was discussed with @viridia on Discord: check that conversation for more details and design ideas.

alice-i-cecile avatar Mar 06 '24 20:03 alice-i-cecile

Me and Xavier will try and tackle this

av1roytman avatar Mar 06 '24 20:03 av1roytman

I had a discussion on discord about the design of what this would look like: https://discord.com/channels/691052431525675048/1038322714320052304/1209594439832567818

The goal is that when you register a callback, you get a handle to that callback, so you can remove or replace it later.

impl<E: EntityEvent> On<E> {
    fn remove<E>(&mut self, handle: ListenerHandle<E>):
    fn replace<E>(&mut self, handle: ListenerHandle<E>, callback: tbd) 
}

aevyrie avatar Mar 06 '24 20:03 aevyrie