1
0
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:
Emil Ernerfeldt
2020-04-19 11:13:24 +02:00
parent 1afda00fc4
commit 6eae91e028
11 changed files with 292 additions and 88 deletions

View File

@@ -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"));
});
}
}