@@ -1125,6 +1125,14 @@ pub fn select_all<Message: 'static>(id: Id) -> Task<Message> {
11251125 task:: effect ( Action :: widget ( operation:: text_input:: select_all ( id) ) )
11261126}
11271127
1128+ /// Produces a [`Task`] that selects a range of the content of the [`TextInput`] with the given
1129+ /// [`Id`].
1130+ pub fn select_range < Message : ' static > ( id : Id , start : usize , end : usize ) -> Task < Message > {
1131+ task:: effect ( Action :: widget ( operation:: text_input:: select_range (
1132+ id, start, end,
1133+ ) ) )
1134+ }
1135+
11281136/// Computes the layout of a [`TextInput`].
11291137#[ allow( clippy:: cast_precision_loss) ]
11301138#[ allow( clippy:: too_many_arguments) ]
@@ -2782,6 +2790,12 @@ impl State {
27822790 self . cursor . select_range ( 0 , usize:: MAX ) ;
27832791 }
27842792
2793+ /// Selects a range of the content of the [`TextInput`].
2794+ #[ inline]
2795+ pub fn select_range ( & mut self , start : usize , end : usize ) {
2796+ self . cursor . select_range ( start, end) ;
2797+ }
2798+
27852799 pub ( super ) fn setting_selection ( & mut self , value : & Value , bounds : Rectangle < f32 > , target : f32 ) {
27862800 let position = if target > 0.0 {
27872801 find_cursor_position ( bounds, value, self , target)
@@ -2842,8 +2856,9 @@ impl operation::TextInput for State {
28422856 todo ! ( )
28432857 }
28442858
2859+ #[ inline]
28452860 fn select_range ( & mut self , start : usize , end : usize ) {
2846- todo ! ( )
2861+ Self :: select_range ( self , start , end ) ;
28472862 }
28482863}
28492864
0 commit comments