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 DispatchEventThe event being dispatched.
current: WidgetIdThe node whose handler is currently running.
phase: PhaseThe phase this invocation belongs to.
target: WidgetIdThe eventual target node (deepest in the path).
Implementations§
Source§impl HandlerCtx<'_>
impl HandlerCtx<'_>
Sourcepub fn add_handler(
&mut self,
id: WidgetId,
phase: Phase,
handler: Box<dyn EventHandler>,
)
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.
Sourcepub fn remove_handlers(&mut self, id: WidgetId)
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> 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