@@ -117,6 +117,7 @@ pub struct Slider<'a> {
117
117
custom_parser : Option < NumParser < ' a > > ,
118
118
trailing_fill : Option < bool > ,
119
119
handle_shape : Option < HandleShape > ,
120
+ update_while_editing : bool ,
120
121
}
121
122
122
123
impl < ' a > Slider < ' a > {
@@ -167,6 +168,7 @@ impl<'a> Slider<'a> {
167
168
custom_parser : None ,
168
169
trailing_fill : None ,
169
170
handle_shape : None ,
171
+ update_while_editing : true ,
170
172
}
171
173
}
172
174
@@ -641,6 +643,16 @@ impl<'a> Slider<'a> {
641
643
let normalized = normalized_from_value ( value, self . range ( ) , & self . spec ) ;
642
644
lerp ( position_range, normalized as f32 )
643
645
}
646
+
647
+ /// Update the value on each key press when text-editing the value.
648
+ ///
649
+ /// Default: `true`.
650
+ /// If `false`, the value will only be updated when user presses enter or deselects the value.
651
+ #[ inline]
652
+ pub fn update_while_editing ( mut self , update : bool ) -> Self {
653
+ self . update_while_editing = update;
654
+ self
655
+ }
644
656
}
645
657
646
658
impl Slider < ' _ > {
@@ -900,7 +912,8 @@ impl Slider<'_> {
900
912
. min_decimals ( self . min_decimals )
901
913
. max_decimals_opt ( self . max_decimals )
902
914
. suffix ( self . suffix . clone ( ) )
903
- . prefix ( self . prefix . clone ( ) ) ;
915
+ . prefix ( self . prefix . clone ( ) )
916
+ . update_while_editing ( self . update_while_editing ) ;
904
917
905
918
match self . clamping {
906
919
SliderClamping :: Never => { }
0 commit comments