diff options
Diffstat (limited to '')
-rw-r--r-- | examples/todos/src/main.rs | 4 | ||||
-rw-r--r-- | native/src/widget/text_input.rs | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index 7186b950..ee0022d5 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -265,8 +265,10 @@ impl Task { self.completed = completed; } TaskMessage::Edit => { + let mut text_input = text_input::State::focused(); + text_input.select_all(); self.state = TaskState::Editing { - text_input: text_input::State::focused(), + text_input, delete_button: button::State::new(), }; } diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index de6032b7..2a0913f3 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -792,6 +792,11 @@ impl State { pub fn move_cursor_to(&mut self, position: usize) { self.cursor.move_to(position); } + + /// Selects all the content of the [`TextInput`]. + pub fn select_all(&mut self) { + self.cursor.select_range(0, usize::MAX); + } } // TODO: Reduce allocations |