Skip to main content

HandlerCtx

Struct HandlerCtx 

Source
pub struct HandlerCtx<'a> {
    pub event: &'a DispatchEvent,
    pub current: WidgetId,
    pub phase: Phase,
    pub target: WidgetId,
    /* private fields */
}
Expand description

Context handed to a handler during dispatch.

A handler reads the event and the current node/phase, and may queue registry edits (which apply only after dispatch). It returns its desired Propagation from EventHandler::handle.

Fields§

§event: &'a DispatchEvent

The event being dispatched.

§current: WidgetId

The node whose handler is currently running.

§phase: Phase

The phase this invocation belongs to.

§target: WidgetId

The eventual target node (deepest in the path).

Implementations§

Source§

impl HandlerCtx<'_>

Source

pub fn add_handler( &mut self, id: WidgetId, phase: Phase, handler: Box<dyn EventHandler>, )

Queue a handler to be added to id for phase after dispatch finishes.

Source

pub fn remove_handlers(&mut self, id: WidgetId)

Queue removal of every handler on id after dispatch finishes.

This is the safe way to “unregister during dispatch”: the removal is recorded now and applied once iteration is complete, so the handler list is never mutated while it is being walked.

Auto Trait Implementations§

§

impl<'a> Freeze for HandlerCtx<'a>

§

impl<'a> !RefUnwindSafe for HandlerCtx<'a>

§

impl<'a> !Send for HandlerCtx<'a>

§

impl<'a> !Sync for HandlerCtx<'a>

§

impl<'a> Unpin for HandlerCtx<'a>

§

impl<'a> UnsafeUnpin for HandlerCtx<'a>

§

impl<'a> !UnwindSafe for HandlerCtx<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.