From 5b7bcc7a9cda8283efa0b331ff7432ef06ed16cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Mon, 24 Nov 2025 11:46:34 +0100 Subject: [PATCH] Improve naming of `Drag` interactions in `text_input` --- widget/src/text_input.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs index 1d22521b..2d6ac701 100644 --- a/widget/src/text_input.rs +++ b/widget/src/text_input.rs @@ -781,7 +781,7 @@ where state.cursor.move_to(position); } - state.is_dragging = Some(Drag::SingleClick); + state.is_dragging = Some(Drag::Select); } click::Kind::Double => { if self.is_secure { @@ -802,8 +802,8 @@ where self.value.next_end_of_word(position), ); - state.is_dragging = Some(Drag::DoubleClick { - click_position: position, + state.is_dragging = Some(Drag::SelectWords { + anchor: position, }); } } @@ -863,24 +863,21 @@ where let selection_before = state.cursor.selection(&value); match is_dragging { - Drag::SingleClick => { + Drag::Select => { state.cursor.select_range( state.cursor.start(&value), position, ); } - Drag::DoubleClick { click_position } => { - if position < *click_position { + Drag::SelectWords { anchor } => { + if position < *anchor { state.cursor.select_range( self.value.previous_start_of_word(position), - self.value - .next_end_of_word(*click_position), + self.value.next_end_of_word(*anchor), ); } else { state.cursor.select_range( - self.value.previous_start_of_word( - *click_position, - ), + self.value.previous_start_of_word(*anchor), self.value.next_end_of_word(position), ); } @@ -1480,8 +1477,8 @@ struct Focus { #[derive(Debug, Clone)] enum Drag { - SingleClick, - DoubleClick { click_position: usize }, + Select, + SelectWords { anchor: usize }, } impl State

{