pub struct EventCtx { /* private fields */ }Expand description
The context passed to Widget::handle_event.
Widgets use it to queue the events they generate. Queueing, instead of calling application
code from inside the Widget, lets callbacks later receive mutable access to both the
application state and every Widget.
Implementations§
Source§impl EventCtx
impl EventCtx
Sourcepub fn emit(&mut self, event: Event)
pub fn emit(&mut self, event: Event)
Queues an event generated by a Widget.
Queued events are delivered to the application in the order in which they were emitted.
§Arguments
event- The event to queue, such asEvent::Clicked { id, button, count }.
Sourcepub fn post<T: Any>(&mut self, target: EventTarget, payload: T)
pub fn post<T: Any>(&mut self, target: EventTarget, payload: T)
Posts a custom event, with the Widget currently handling an event as its source.
The event is queued behind the events already waiting and delivered later, in order, never
from inside this call. See CustomEvent.
§Arguments
target- WhichWidgets receive the event.payload- The application’s data; receivers read it withEvent::payload.
Sourcepub fn request_animation(&mut self)
pub fn request_animation(&mut self)
Asks for an Event::Tick on the next frame, for the Widget currently handling an event.
The request is for one frame, like a browser’s requestAnimationFrame: a Widget that
keeps animating calls this again each time it handles a Tick, and stops by not calling
it. Only Widgets with EventMask::TIMER in their mask receive the tick. Does nothing
outside event handling.
Sourcepub fn phase(&self) -> EventPhase
pub fn phase(&self) -> EventPhase
Returns the phase of delivery the current event is in.
§Returns
EventPhase::Target unless the event is being captured or bubbled.
Sourcepub fn into_events(self) -> Vec<Event>
pub fn into_events(self) -> Vec<Event>
Consumes the context and returns the queued events.
§Returns
The queued events, in the order emitted.