Merge pull request #776 from AldoMX/master
Added `select_all` method to `TextInput`.
This commit is contained in:
commit
587dbbca42
3 changed files with 14 additions and 1 deletions
|
|
@ -265,8 +265,11 @@ impl Task {
|
||||||
self.completed = completed;
|
self.completed = completed;
|
||||||
}
|
}
|
||||||
TaskMessage::Edit => {
|
TaskMessage::Edit => {
|
||||||
|
let mut text_input = text_input::State::focused();
|
||||||
|
text_input.select_all();
|
||||||
|
|
||||||
self.state = TaskState::Editing {
|
self.state = TaskState::Editing {
|
||||||
text_input: text_input::State::focused(),
|
text_input,
|
||||||
delete_button: button::State::new(),
|
delete_button: button::State::new(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -786,6 +786,11 @@ impl State {
|
||||||
pub fn move_cursor_to(&mut self, position: usize) {
|
pub fn move_cursor_to(&mut self, position: usize) {
|
||||||
self.cursor.move_to(position);
|
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
|
// TODO: Reduce allocations
|
||||||
|
|
|
||||||
|
|
@ -223,4 +223,9 @@ impl State {
|
||||||
// TODO
|
// TODO
|
||||||
Self::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Selects all the content of the [`TextInput`].
|
||||||
|
pub fn select_all(&mut self) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue