Browse Source

Fix Shift+Tab behavior when no widget is focused (#3498)

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo cranky`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review you PR, but my time is limited!
-->

If no widget is focused (such as when an application just started or
after Escape was pressed), pressing Shift+Tab does not set the focus to
the last widget. I think this PR fixes that.
pull/3543/head
Arnold Loubriat 1 year ago
committed by GitHub
parent
commit
85e14e89bd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      crates/egui/src/memory.rs

7
crates/egui/src/memory.rs

@ -415,6 +415,13 @@ impl Focus {
// nothing has focus and the user pressed tab - give focus to the first widgets that wants it:
self.focused_widget = Some(FocusWidget::new(id));
self.reset_focus();
} else if self.focus_direction == FocusDirection::Previous
&& self.focused_widget.is_none()
&& !self.give_to_next
{
// nothing has focus and the user pressed Shift+Tab - give focus to the last widgets that wants it:
self.focused_widget = self.last_interested.map(FocusWidget::new);
self.reset_focus();
}
self.last_interested = Some(id);

Loading…
Cancel
Save