mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
Distinguish ids that need to be unique and warn about name clashes
This commit is contained in:
@@ -125,6 +125,28 @@ impl ExampleApp {
|
||||
region.foldable("Slider example", |region| {
|
||||
value_ui(&mut self.slider_value, region);
|
||||
});
|
||||
|
||||
region.foldable("Name clash example", |region| {
|
||||
region.add(label!("\
|
||||
Regions that store state require unique identifiers so we can track their state between frames. \
|
||||
Identifiers are normally derived from the titles of the widget."));
|
||||
|
||||
region.add(label!("\
|
||||
For instance, foldable regions needs to store wether or not they are open. \
|
||||
If you fail to give them unique names then clicking one will open both. \
|
||||
To help you debug this, a error message is printed on screen:"));
|
||||
|
||||
region.foldable("Foldable", |region| {
|
||||
region.add(label!("Contents of first folddable region"));
|
||||
});
|
||||
region.foldable("Foldable", |region| {
|
||||
region.add(label!("Contents of second folddable region"));
|
||||
});
|
||||
|
||||
region.add(label!("Most widgets don't need unique names, but are tracked based on their position on screen. For instance, buttons:"));
|
||||
region.add(Button::new("Button"));
|
||||
region.add(Button::new("Button"));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user