Skip to main content

Widget

Trait Widget 

Source
pub trait Widget: 'static {
    // Required methods
    fn id(&self) -> &str;
    fn open(&mut self, ui: &mut UiContext<'_>);
    fn update(&mut self, ui: &mut UiContext<'_>) -> Status;

    // Provided methods
    fn resume(&mut self, value: Option<Value>, ui: &mut UiContext<'_>) { ... }
    fn value(&self, item: &str) -> Option<Value> { ... }
    fn music(&self) -> Option<&str> { ... }
}
Expand description

A virtual UI element. Implement this to create your own widgets.

Required Methods§

Source

fn id(&self) -> &str

Identifier used in events.

Source

fn open(&mut self, ui: &mut UiContext<'_>)

Called once when the widget becomes active. Announce yourself here.

Source

fn update(&mut self, ui: &mut UiContext<'_>) -> Status

Called every frame while this widget is on top of the stack.

Provided Methods§

Source

fn resume(&mut self, value: Option<Value>, ui: &mut UiContext<'_>)

Called when the widget becomes the top again after the one above closed. value is what the closed widget passed with Status::CloseWith.

Source

fn value(&self, item: &str) -> Option<Value>

Current value of an item, used by Ui::value.

Source

fn music(&self) -> Option<&str>

Music that plays while this widget is open, see Menu::music. Widgets above it without music of their own keep it playing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§