mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 14:50:03 -04:00
impl<F> Widget for F where F: FnOnce(&mut Ui) -> Response
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(toggle(bool))` (instead of `toggle(ui, bool)`)
This commit is contained in:
@@ -156,7 +156,10 @@ impl super::View for WidgetGallery {
|
||||
ui.end_row();
|
||||
|
||||
ui.label("Custom widget:");
|
||||
super::toggle_switch::demo(ui, boolean);
|
||||
ui.add(super::toggle_switch::toggle(boolean)).on_hover_text(
|
||||
"It's easy to create your own widgets!\n\
|
||||
This toggle switch is just 15 lines of code.",
|
||||
);
|
||||
ui.end_row();
|
||||
|
||||
ui.label("Plot:");
|
||||
|
||||
Reference in New Issue
Block a user