Trait egui::widgets::Widget  [−][src]
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
Implementations on Foreign Types
Implementors
This enables functions that return impl Widget, so that you can
create a widget by just returning a lambda from a function.
For instance: ui.add(slider_vec2(&mut vec2)); with:
pub fn slider_vec2(value: &mut egui::Vec2) -> impl egui::Widget + '_ {
   move |ui: &mut egui::Ui| {
       ui.horizontal(|ui| {
           ui.add(egui::Slider::new(&mut value.x, 0.0..=1.0).text("x"));
           ui.add(egui::Slider::new(&mut value.y, 0.0..=1.0).text("y"));
       })
       .response
   }
}