diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f4938ddb5..e0799302ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/druid/src/widget/textbox.rs b/druid/src/widget/textbox.rs index 651ac5b8e5..dd05a97848 100644 --- a/druid/src/widget/textbox.rs +++ b/druid/src/widget/textbox.rs @@ -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); @@ -379,8 +379,11 @@ impl Widget 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(); } _ => (), }