From 52ca464468251e15d95f2e16e9debbc4715e18bb Mon Sep 17 00:00:00 2001 From: hacknus Date: Fri, 1 Nov 2024 10:32:53 +0100 Subject: [PATCH] mark response as changed when one of the two sliders is dragged --- crates/egui/src/widgets/double_slider.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/double_slider.rs b/crates/egui/src/widgets/double_slider.rs index 224d07efbd6..d1cc52531b9 100644 --- a/crates/egui/src/widgets/double_slider.rs +++ b/crates/egui/src/widgets/double_slider.rs @@ -122,7 +122,7 @@ impl<'a> Widget for DoubleSlider<'a> { // calculate height let height = 2.0 * self.control_point_radius + 2.0 * OFFSET; - let (response, painter) = + let (mut response, painter) = ui.allocate_painter(Vec2::new(self.width, height), Sense::hover()); let mut left_edge = response.rect.left_center(); left_edge.x += self.control_point_radius; @@ -152,6 +152,10 @@ impl<'a> Widget for DoubleSlider<'a> { let point_id = response.id.with(0); let point_response = ui.interact(point_rect, point_id, Sense::drag()); + if point_response.dragged() { + response.mark_changed(); + } + // handle logic *self.left_slider += self.x_to_val(point_response.drag_delta().x); if *self.right_slider < *self.left_slider + self.separation_distance { @@ -186,6 +190,10 @@ impl<'a> Widget for DoubleSlider<'a> { let point_id = response.id.with(1); let point_response = ui.interact(point_rect, point_id, Sense::drag()); + if point_response.dragged() { + response.mark_changed(); + } + // handle logic *self.right_slider += self.x_to_val(point_response.drag_delta().x); if *self.left_slider > *self.right_slider - self.separation_distance {