diff --git a/emigui/src/widgets.rs b/emigui/src/widgets.rs index df186967..8ba6b6c6 100644 --- a/emigui/src/widgets.rs +++ b/emigui/src/widgets.rs @@ -260,6 +260,7 @@ pub struct Slider<'a> { precision: usize, text_color: Option, text_on_top: Option, + id: Option, } impl<'a> Slider<'a> { @@ -272,6 +273,7 @@ impl<'a> Slider<'a> { precision: 3, text_on_top: None, text_color: None, + id: None, } } @@ -350,6 +352,10 @@ impl<'a> Widget for Slider<'a> { let font = ®ion.fonts()[text_style]; if let Some(text) = &self.text { + if self.id.is_none() { + self.id = Some(Id::new(text)); + } + let text_on_top = self.text_on_top.unwrap_or_default(); let text_color = self.text_color; let value = (self.get_set_value)(None); @@ -382,7 +388,7 @@ impl<'a> Widget for Slider<'a> { let height = font.line_spacing().max(region.style().clickable_diameter); let handle_radius = height / 2.5; - let id = region.make_position_id(); // TODO: causes problems for style settings :/ + let id = self.id.unwrap_or_else(|| region.make_position_id()); let interact = region.reserve_space( Vec2 {