From 98cf9c455a201fec3069f415ce2ddf5e88def242 Mon Sep 17 00:00:00 2001 From: bansheerubber Date: Fri, 5 Jun 2020 09:19:46 -0700 Subject: added move_cursor_to --- native/src/widget/text_input.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'native') diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index 0dbcc3d6..c821247f 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -699,6 +699,14 @@ impl State { pub fn move_cursor_to_end(&mut self, value: &String) { self.cursor.move_to(value.len()); } + + /// Moves the [`Cursor`] of the [`TextInput`] to an arbitrary location. + /// + /// [`Cursor`]: struct.Cursor.html + /// [`TextInput`]: struct.TextInput.html + pub fn move_cursor_to(&mut self, position: usize) { + self.cursor.move_to(position); + } } // TODO: Reduce allocations -- cgit