Trait egui::widgets::Widget[][src]

pub trait Widget {
    fn ui(self, ui: &mut Ui) -> Response;
}
Expand description

Anything implementing Widget can be added to a Ui with Ui::add.

[Button], [Label], Slider, etc all implement the Widget trait.

Note that the widgets (Button, TextEdit etc) are builders, and not objects that hold state.

Tip: you can impl Widget for &mut YourThing { }.

|ui: &mut Ui| -> Response { … } also implements Widget.

Required methods

Allocate space, interact, paint, and return a Response.

Note that this consumes self. This is because most widgets (Button, TextEdit etc) are builders

Tip: you can impl Widget for &mut YourObject { }.

Implementations on Foreign Types

Implementors