Browse Source

Don't call scroll if TextEdit is fully in view (#1779)

* Don't call scroll if TextEdit is fully in view

* Explain why the new logic was added

* cargo fmt

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
pull/1793/head
Barugon 2 years ago
committed by GitHub
parent
commit
433719717a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      egui/src/widgets/text_edit/builder.rs

3
egui/src/widgets/text_edit/builder.rs

@ -610,7 +610,8 @@ impl<'t> TextEdit<'t> {
&cursor_range.primary,
);
if response.changed || selection_changed {
let is_fully_visible = ui.clip_rect().contains_rect(rect); // TODO: remove this HACK workaround for https://github.com/emilk/egui/issues/1531
if (response.changed || selection_changed) && !is_fully_visible {
ui.scroll_to_rect(cursor_pos, None); // keep cursor in view
}

Loading…
Cancel
Save