From 548c520b971ff0f6c7d4dbb3d5650a02768d9b10 Mon Sep 17 00:00:00 2001 From: DataTriny Date: Mon, 23 Oct 2023 21:13:35 +0200 Subject: [PATCH] Fix Shift+Tab behavior when no widget is focused --- crates/egui/src/memory.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/egui/src/memory.rs b/crates/egui/src/memory.rs index 2c56d967248..908d9f7bb7c 100644 --- a/crates/egui/src/memory.rs +++ b/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);