Improve naming of Drag interactions in text_input
This commit is contained in:
parent
1aa8aaf818
commit
5b7bcc7a9c
1 changed files with 10 additions and 13 deletions
|
|
@ -781,7 +781,7 @@ where
|
||||||
state.cursor.move_to(position);
|
state.cursor.move_to(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
state.is_dragging = Some(Drag::SingleClick);
|
state.is_dragging = Some(Drag::Select);
|
||||||
}
|
}
|
||||||
click::Kind::Double => {
|
click::Kind::Double => {
|
||||||
if self.is_secure {
|
if self.is_secure {
|
||||||
|
|
@ -802,8 +802,8 @@ where
|
||||||
self.value.next_end_of_word(position),
|
self.value.next_end_of_word(position),
|
||||||
);
|
);
|
||||||
|
|
||||||
state.is_dragging = Some(Drag::DoubleClick {
|
state.is_dragging = Some(Drag::SelectWords {
|
||||||
click_position: position,
|
anchor: position,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -863,24 +863,21 @@ where
|
||||||
let selection_before = state.cursor.selection(&value);
|
let selection_before = state.cursor.selection(&value);
|
||||||
|
|
||||||
match is_dragging {
|
match is_dragging {
|
||||||
Drag::SingleClick => {
|
Drag::Select => {
|
||||||
state.cursor.select_range(
|
state.cursor.select_range(
|
||||||
state.cursor.start(&value),
|
state.cursor.start(&value),
|
||||||
position,
|
position,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Drag::DoubleClick { click_position } => {
|
Drag::SelectWords { anchor } => {
|
||||||
if position < *click_position {
|
if position < *anchor {
|
||||||
state.cursor.select_range(
|
state.cursor.select_range(
|
||||||
self.value.previous_start_of_word(position),
|
self.value.previous_start_of_word(position),
|
||||||
self.value
|
self.value.next_end_of_word(*anchor),
|
||||||
.next_end_of_word(*click_position),
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
state.cursor.select_range(
|
state.cursor.select_range(
|
||||||
self.value.previous_start_of_word(
|
self.value.previous_start_of_word(*anchor),
|
||||||
*click_position,
|
|
||||||
),
|
|
||||||
self.value.next_end_of_word(position),
|
self.value.next_end_of_word(position),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -1480,8 +1477,8 @@ struct Focus {
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
enum Drag {
|
enum Drag {
|
||||||
SingleClick,
|
Select,
|
||||||
DoubleClick { click_position: usize },
|
SelectWords { anchor: usize },
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<P: text::Paragraph> State<P> {
|
impl<P: text::Paragraph> State<P> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue