Skip to content

Commit

Permalink
Fix #1124, #1125 (#1276)
Browse files Browse the repository at this point in the history
* Fix #1124, #1125

* fix clippy

* update CHANGELOG.md

Co-authored-by: Colin Rofls <[email protected]>
  • Loading branch information
sysint64 and cmyr authored Oct 5, 2020
1 parent 9bae2f1 commit db64ac1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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

0 comments on commit db64ac1

Please sign in to comment.