pub struct Ui<'a> { /* private fields */ }Expand description
The handle passed to callbacks.
It gives callbacks access to the Widgets in the window, by ID and concrete type, and lets
them stop the Engine. It borrows the Engine’s widget tree only for the duration of the
callback.
Implementations§
Source§impl<'a> Ui<'a>
impl<'a> Ui<'a>
Sourcepub fn cancel_timer(&mut self, id: TimerId) -> bool
pub fn cancel_timer(&mut self, id: TimerId) -> bool
Cancels a timer started with Engine::on_timer.
Safe to call from any callback, including the timer’s own: a timer cancelled while the
timers due this frame are running does not fire afterwards. Emits
EngineEvent::TimerCancelled when a waiting timer was stopped.
§Arguments
id- The timer to cancel.
§Returns
true if the timer was still scheduled; false if it was a one-shot that already fired,
or was already cancelled.
Sourcepub fn request_animation(&mut self, id: WidgetId)
pub fn request_animation(&mut self, id: WidgetId)
Asks for an Event::Tick for a Widget on the next frame. See
WidgetCache::request_animation.
§Arguments
id- TheWidgetto tick.
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, to be delivered after the callbacks currently running.
The event is queued, never delivered from inside this call. Posting from a custom-event
callback is allowed; at most MAX_CUSTOM_EVENTS_PER_FRAME custom events are delivered per
frame, and the rest are discarded with an EngineEvent::CustomEventDropped.
§Arguments
target- WhichWidgets receive the event.payload- The application’s data; receivers read it withEvent::payload.
Sourcepub fn set_event_mask(&mut self, mask: EventMask)
pub fn set_event_mask(&mut self, mask: EventMask)
Changes the run loop’s event mask. See Engine::set_event_mask.
§Arguments
mask- The new mask; it applies from the next event.
Sourcepub fn set_widget_event_mask(&mut self, id: WidgetId, mask: EventMask)
pub fn set_widget_event_mask(&mut self, id: WidgetId, mask: EventMask)
Changes a Widget’s event mask. See WidgetCache::set_event_mask.
§Arguments
id- The ID of theWidget.mask- The new mask.
Sourcepub fn widgets(&mut self) -> &mut WidgetCache
pub fn widgets(&mut self) -> &mut WidgetCache
Returns the window’s widget tree.
Use it to add Widgets from a callback, or to reach a Widget without knowing its concrete
type.
§Returns
The WidgetCache holding every Widget in the window.
Sourcepub fn set_focus(&mut self, id: WidgetId) -> bool
pub fn set_focus(&mut self, id: WidgetId) -> bool
Gives the keyboard focus to a Widget. See WidgetCache::set_focus.
§Arguments
id- The ID of theWidget.
§Returns
true if the Widget has focus afterward; false if it cannot take focus.
Sourcepub fn focused(&self) -> Option<WidgetId>
pub fn focused(&self) -> Option<WidgetId>
Returns the Widget that has the keyboard focus.
§Returns
The ID of the focused Widget, or None if nothing has focus.
Sourcepub fn shutdown(&mut self)
pub fn shutdown(&mut self)
Stops the Engine.
The run loop finishes the current batch of events, then returns the application state from
Engine::run; in the event-loop style, Engine::next_event returns None.