pub struct EventHandlerManager<Ms> { /* private fields */ }
Expand description

Manages event handlers and listeners for elements.

Implementations§

source§

impl<Ms> EventHandlerManager<Ms>

source

pub fn new() -> Self

Creates an empty manager instance.

source

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.

source

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.

source

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.

source

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>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Ms: Debug> Debug for EventHandlerManager<Ms>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Ms: Default> Default for EventHandlerManager<Ms>

source§

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>

source§

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> !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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V