Added select_all method to TextInput.

This commit is contained in:
Aldo Fregoso 2021-03-13 14:50:59 -06:00
parent c1f70f1e92
commit 57247106b9
2 changed files with 8 additions and 1 deletions

View file

@ -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(),
};
}

View file

@ -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