Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1124, #1125 #1276

Merged
merged 4 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ You can find its changes [documented below](#060---2020-06-01).
- Windows: fix crash on resize from incompatible resources ([#1191 by [@raphlinus]])
- GTK: Related dependencies are now optional, facilitating a pure X11 build. ([#1241] by [@finnerale])
- `widget::Image` now computes the layout correctly when unbound in one direction. ([#1189] by [@JAicewizard])
- TextBox doesn't reset position after unfocused. ([#1276] by [@sysint64])
- Able to select text in multiple TextBoxes at once. ([#1276] by [@sysint64])
- The scroll bar now shows when the contents of a scrollable area change size. ([#1278] by [@Majora320])

### Visual
Expand Down Expand Up @@ -486,6 +488,7 @@ Last release without a changelog :(
[#1251]: https://github.com/linebender/druid/pull/1251
[#1252]: https://github.com/linebender/druid/pull/1252
[#1255]: https://github.com/linebender/druid/pull/1255
[#1276]: https://github.com/linebender/druid/pull/1276
[#1278]: https://github.com/linebender/druid/pull/1278

[Unreleased]: https://github.com/linebender/druid/compare/v0.6.0...master
Expand Down
9 changes: 6 additions & 3 deletions druid/src/widget/textbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl TextBox {
}

/// Edit a selection using a `Movement`.
fn move_selection(&mut self, mvmnt: Movement, text: &mut String, modify: bool) {
fn move_selection(&mut self, mvmnt: Movement, text: &impl EditableText, modify: bool) {
// This movement function should ensure all movements are legit.
// If they aren't, that's a problem with the movement function.
self.selection = movement(mvmnt, self.selection, text, modify);
Expand Down Expand Up @@ -379,8 +379,11 @@ impl Widget<String> for TextBox {
ctx.register_for_focus();
self.text.set_text(data.as_str().into());
}
LifeCycle::FocusChanged(true) => {
self.reset_cursor_blink(ctx.request_timer(CURSOR_BLINK_DURATION))
LifeCycle::FocusChanged(_) => {
self.move_selection(Movement::StartOfDocument, data, false);
self.update_hscroll();
self.reset_cursor_blink(ctx.request_timer(CURSOR_BLINK_DURATION));
ctx.request_paint();
}
_ => (),
}
Expand Down