Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/widget/text_input/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,14 @@ pub fn select_all<Message: 'static>(id: Id) -> Task<Message> {
task::effect(Action::widget(operation::text_input::select_all(id)))
}

/// Produces a [`Task`] that selects a range of the content of the [`TextInput`] with the given
/// [`Id`].
pub fn select_range<Message: 'static>(id: Id, start: usize, end: usize) -> Task<Message> {
task::effect(Action::widget(operation::text_input::select_range(
id, start, end,
)))
}

/// Computes the layout of a [`TextInput`].
#[allow(clippy::cast_precision_loss)]
#[allow(clippy::too_many_arguments)]
Expand Down Expand Up @@ -2782,6 +2790,12 @@ impl State {
self.cursor.select_range(0, usize::MAX);
}

/// Selects a range of the content of the [`TextInput`].
#[inline]
pub fn select_range(&mut self, start: usize, end: usize) {
self.cursor.select_range(start, end);
}

pub(super) fn setting_selection(&mut self, value: &Value, bounds: Rectangle<f32>, target: f32) {
let position = if target > 0.0 {
find_cursor_position(bounds, value, self, target)
Expand Down Expand Up @@ -2842,8 +2856,9 @@ impl operation::TextInput for State {
todo!()
}

#[inline]
fn select_range(&mut self, start: usize, end: usize) {
todo!()
Self::select_range(self, start, end);
}
}

Expand Down
Loading