diff --git a/crates/egui/src/widgets/drag_value.rs b/crates/egui/src/widgets/drag_value.rs index 26bbc38cb795..181faa3c32fe 100644 --- a/crates/egui/src/widgets/drag_value.rs +++ b/crates/egui/src/widgets/drag_value.rs @@ -111,7 +111,6 @@ impl<'a> DragValue<'a> { /// If set to `true`, all incoming and outgoing values will be clamped to the sliding [`Self::range`] (if any). /// /// If set to `false`, a value outside of the range that is set programmatically or by user input will not be changed. - /// Dragging will be restricted to the range regardless of this setting. /// Default: `true`. #[inline] pub fn clamp_to_range(mut self, clamp_to_range: bool) -> Self { @@ -608,8 +607,11 @@ impl<'a> Widget for DragValue<'a> { ); let rounded_new_value = emath::round_to_decimals(rounded_new_value, auto_decimals); - // Dragging will always clamp the value to the range. - let rounded_new_value = clamp_value_to_range(rounded_new_value, range.clone()); + let rounded_new_value = if clamp_to_range { + clamp_value_to_range(rounded_new_value, range.clone()) + } else { + rounded_new_value + }; set(&mut get_set_value, rounded_new_value); ui.data_mut(|data| data.insert_temp::(id, precise_value)); diff --git a/crates/egui_demo_lib/src/demo/sliders.rs b/crates/egui_demo_lib/src/demo/sliders.rs index 2f3cf7faedae..0e8bb56026ca 100644 --- a/crates/egui_demo_lib/src/demo/sliders.rs +++ b/crates/egui_demo_lib/src/demo/sliders.rs @@ -190,7 +190,7 @@ impl crate::View for Sliders { ui.checkbox(clamp_to_range, "Clamp to range"); ui.label("If true, the slider will clamp incoming and outgoing values to the given range."); - ui.label("If false, the slider can shows values outside its range, and you can manually enter values outside the range."); + ui.label("If false, the slider can show values outside its range, and you can manually enter values outside the range."); ui.add_space(8.0); ui.checkbox(smart_aim, "Smart Aim");