diff --git a/egui/src/containers/collapsing_header.rs b/egui/src/containers/collapsing_header.rs index 3f93e5b9..4d55b621 100644 --- a/egui/src/containers/collapsing_header.rs +++ b/egui/src/containers/collapsing_header.rs @@ -179,7 +179,7 @@ impl CollapsingHeader { // TODO: horizontal layout, with icon and text as labels. Insert background behind using Frame. let title = label.text(); - let id = ui.make_unique_id(title); + let id = ui.make_unique_child_id(title); let available = ui.available_finite(); let text_pos = available.min + vec2(ui.style().indent, 0.0); diff --git a/egui/src/containers/menu.rs b/egui/src/containers/menu.rs index 393fd72b..a6ec78de 100644 --- a/egui/src/containers/menu.rs +++ b/egui/src/containers/menu.rs @@ -55,7 +55,7 @@ fn menu_impl<'c>( ) { let title = title.into(); let bar_id = ui.id(); - let menu_id = Id::new(&title); + let menu_id = bar_id.with(&title); let mut bar_state = ui .memory() diff --git a/egui/src/ui.rs b/egui/src/ui.rs index e8e66f30..66aabcb5 100644 --- a/egui/src/ui.rs +++ b/egui/src/ui.rs @@ -280,7 +280,7 @@ impl Ui { /// Use this to generate widget ids for widgets that have persistent state in Memory. /// If the `id_source` is not unique within this ui /// then an error will be printed at the current cursor position. - pub fn make_unique_id(&self, id_source: IdSource) -> Id + pub fn make_unique_child_id(&self, id_source: IdSource) -> Id where IdSource: Hash + std::fmt::Debug, { diff --git a/egui/src/widgets/slider.rs b/egui/src/widgets/slider.rs index 3efd5d79..026aaaa0 100644 --- a/egui/src/widgets/slider.rs +++ b/egui/src/widgets/slider.rs @@ -105,7 +105,7 @@ impl<'a> Widget for Slider<'a> { if let Some(text) = &self.text { if self.id.is_none() { - self.id = Some(Id::new(text)); + self.id = Some(ui.make_unique_child_id(text)); } let text_on_top = self.text_on_top.unwrap_or_default();