Skip to content

Commit

Permalink
Merge pull request #637 from b-guild/textbox
Browse files Browse the repository at this point in the history
Auto-select text on focusing TextBox
  • Loading branch information
mrDIMAS committed Apr 22, 2024
2 parents ea2fbf9 + 59ae142 commit 25a2296
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fyrox-ui/src/text_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1169,8 +1169,17 @@ impl Control for TextBox {
WidgetMessage::Focus => {
if message.direction() == MessageDirection::FromWidget {
self.reset_blink();
self.selection_range.set_value_and_mark_modified(None);
self.has_focus = true;
let end = self.end_position();
if end != Position::default() {
self.set_caret_position(end);
self.selection_range.set_value_and_mark_modified(Some(
SelectionRange {
begin: Position::default(),
end,
},
));
}
}
}
WidgetMessage::Unfocus => {
Expand Down

0 comments on commit 25a2296

Please sign in to comment.