From 2684929a5d9efa2d0fd869a7cbd33d13ea27162a Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 28 Dec 2021 10:08:28 +0100 Subject: [PATCH] Make Memory::lock_focus public closes https://github.com/emilk/egui/issues/993 --- egui/src/memory.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/egui/src/memory.rs b/egui/src/memory.rs index b5350f5c..f8d615ed 100644 --- a/egui/src/memory.rs +++ b/egui/src/memory.rs @@ -327,13 +327,16 @@ impl Memory { self.interaction.focus.id } - pub(crate) fn lock_focus(&mut self, id: Id, lock_focus: bool) { + /// Prevent keyboard focus from moving away from this widget even if users presses the tab key. + /// You must first give focus to the widget before calling this. + pub fn lock_focus(&mut self, id: Id, lock_focus: bool) { if self.had_focus_last_frame(id) && self.has_focus(id) { self.interaction.focus.is_focus_locked = lock_focus; } } - pub(crate) fn has_lock_focus(&mut self, id: Id) -> bool { + /// Is the keyboard focus locked on this widget? If so the focus won't move even if the user presses the tab key. + pub fn has_lock_focus(&mut self, id: Id) -> bool { if self.had_focus_last_frame(id) && self.has_focus(id) { self.interaction.focus.is_focus_locked } else {