Skip to content

Commit 587dbbc

Browse files
authored
Merge pull request #776 from AldoMX/master
Added `select_all` method to `TextInput`.
2 parents f076649 + 72d5d9b commit 587dbbc

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

examples/todos/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,11 @@ impl Task {
265265
self.completed = completed;
266266
}
267267
TaskMessage::Edit => {
268+
let mut text_input = text_input::State::focused();
269+
text_input.select_all();
270+
268271
self.state = TaskState::Editing {
269-
text_input: text_input::State::focused(),
272+
text_input,
270273
delete_button: button::State::new(),
271274
};
272275
}

native/src/widget/text_input.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,11 @@ impl State {
786786
pub fn move_cursor_to(&mut self, position: usize) {
787787
self.cursor.move_to(position);
788788
}
789+
790+
/// Selects all the content of the [`TextInput`].
791+
pub fn select_all(&mut self) {
792+
self.cursor.select_range(0, usize::MAX);
793+
}
789794
}
790795

791796
// TODO: Reduce allocations

web/src/widget/text_input.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,9 @@ impl State {
223223
// TODO
224224
Self::default()
225225
}
226+
227+
/// Selects all the content of the [`TextInput`].
228+
pub fn select_all(&mut self) {
229+
// TODO
230+
}
226231
}

0 commit comments

Comments
 (0)