pub struct EventHandlerManager<Ms> { /* private fields */ }
Expand description
Manages event handlers and listeners for elements.
Implementations§
source§impl<Ms> EventHandlerManager<Ms>
impl<Ms> EventHandlerManager<Ms>
sourcepub fn with_event_handlers(event_handlers: Vec<EventHandler<Ms>>) -> Self
pub fn with_event_handlers(event_handlers: Vec<EventHandler<Ms>>) -> Self
Creates a new manager instance with given event handlers.
It doesn’t create listeners automatically - you have to call attach_listeners
.
sourcepub fn attach_listeners(
&mut self,
event_target: impl Into<EventTarget> + 'static,
old_manager: Option<&mut EventHandlerManager<Ms>>,
mailbox: &Mailbox<Ms>
)
pub fn attach_listeners( &mut self, event_target: impl Into<EventTarget> + 'static, old_manager: Option<&mut EventHandlerManager<Ms>>, mailbox: &Mailbox<Ms> )
Creates missing listeners and attaches them to the given event_target
.
It can reuse listeners from the old_manager
.
sourcepub fn add_event_handlers(&mut self, event_handlers: Vec<EventHandler<Ms>>)
pub fn add_event_handlers(&mut self, event_handlers: Vec<EventHandler<Ms>>)
Add new event handlers into the manager.
It doesn’t create listeners automatically - you have to call attach_listeners
.
sourcepub fn take_and_setup_listener(
&mut self,
trigger: &Ev,
event_handlers: Rc<RefCell<Vec<EventHandler<Ms>>>>
) -> Option<Listener<Ms>>
pub fn take_and_setup_listener( &mut self, trigger: &Ev, event_handlers: Rc<RefCell<Vec<EventHandler<Ms>>>> ) -> Option<Listener<Ms>>
This method is used in attach_listeners
method to move listeners from the old manager.
Trait Implementations§
source§impl<Ms> Clone for EventHandlerManager<Ms>
impl<Ms> Clone for EventHandlerManager<Ms>
source§impl<Ms: Debug> Debug for EventHandlerManager<Ms>
impl<Ms: Debug> Debug for EventHandlerManager<Ms>
source§impl<Ms: Default> Default for EventHandlerManager<Ms>
impl<Ms: Default> Default for EventHandlerManager<Ms>
source§fn default() -> EventHandlerManager<Ms>
fn default() -> EventHandlerManager<Ms>
Returns the “default value” for a type. Read more
source§impl<Ms: 'static, OtherMs: 'static> MessageMapper<Ms, OtherMs> for EventHandlerManager<Ms>
impl<Ms: 'static, OtherMs: 'static> MessageMapper<Ms, OtherMs> for EventHandlerManager<Ms>
source§fn map_msg(
self,
f: impl FnOnce(Ms) -> OtherMs + 'static + Clone
) -> EventHandlerManager<OtherMs>
fn map_msg( self, f: impl FnOnce(Ms) -> OtherMs + 'static + Clone ) -> EventHandlerManager<OtherMs>
Note: Listeners will be automatically detached and removed.
You have to call attach_listeners
to recreate them.