[slider] bug fix: generate unique id for sliders

This commit is contained in:
Emil Ernerfeldt 2020-06-03 09:56:06 +02:00
parent bea7e3a52e
commit c35494e4ec
4 changed files with 4 additions and 4 deletions

View file

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

View file

@ -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()

View file

@ -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<IdSource>(&self, id_source: IdSource) -> Id
pub fn make_unique_child_id<IdSource>(&self, id_source: IdSource) -> Id
where
IdSource: Hash + std::fmt::Debug,
{

View file

@ -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();