diff --git a/crates/egui/src/widgets/slider.rs b/crates/egui/src/widgets/slider.rs index 6dfb1df6605..1d4c5f8d998 100644 --- a/crates/egui/src/widgets/slider.rs +++ b/crates/egui/src/widgets/slider.rs @@ -605,13 +605,14 @@ impl<'a> Slider<'a> { let kb_step = increment as f32 - decrement as f32; if kb_step != 0.0 { + let ui_point_per_step = 1.0; // move this many ui points for each kb_step let prev_value = self.get_value(); let prev_position = self.position_from_value(prev_value, position_range); - let new_position = prev_position + kb_step; + let new_position = prev_position + ui_point_per_step * kb_step; let new_value = match self.step { Some(step) => prev_value + (kb_step as f64 * step), None if self.smart_aim => { - let aim_radius = ui.input(|i| i.aim_radius()); + let aim_radius = 0.49 * ui_point_per_step; // Chosen so we don't include `prev_value` in the search. emath::smart_aim::best_in_range_f64( self.value_from_position(new_position - aim_radius, position_range), self.value_from_position(new_position + aim_radius, position_range),