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.
type SelfWithOtherMs = EventHandlerManager<OtherMs>
Auto Trait Implementations§
impl<Ms> Freeze for EventHandlerManager<Ms>
impl<Ms> !RefUnwindSafe for EventHandlerManager<Ms>
impl<Ms> !Send for EventHandlerManager<Ms>
impl<Ms> !Sync for EventHandlerManager<Ms>
impl<Ms> Unpin for EventHandlerManager<Ms>
impl<Ms> !UnwindSafe for EventHandlerManager<Ms>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more