feat(text_input): add select_range method and Task function
This commit is contained in:
parent
254c13cfc4
commit
380b341bdc
1 changed files with 16 additions and 1 deletions
|
|
@ -1125,6 +1125,14 @@ pub fn select_all<Message: 'static>(id: Id) -> Task<Message> {
|
||||||
task::effect(Action::widget(operation::text_input::select_all(id)))
|
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`].
|
/// Computes the layout of a [`TextInput`].
|
||||||
#[allow(clippy::cast_precision_loss)]
|
#[allow(clippy::cast_precision_loss)]
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
|
@ -2782,6 +2790,12 @@ impl State {
|
||||||
self.cursor.select_range(0, usize::MAX);
|
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) {
|
pub(super) fn setting_selection(&mut self, value: &Value, bounds: Rectangle<f32>, target: f32) {
|
||||||
let position = if target > 0.0 {
|
let position = if target > 0.0 {
|
||||||
find_cursor_position(bounds, value, self, target)
|
find_cursor_position(bounds, value, self, target)
|
||||||
|
|
@ -2842,8 +2856,9 @@ impl operation::TextInput for State {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn select_range(&mut self, start: usize, end: usize) {
|
fn select_range(&mut self, start: usize, end: usize) {
|
||||||
todo!()
|
Self::select_range(self, start, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue