Skip to content

Commit

Permalink
Make Memory::lock_focus public
Browse files Browse the repository at this point in the history
closes #993
  • Loading branch information
emilk committed Dec 28, 2021
1 parent c639961 commit 2684929
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions egui/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2684929

Please sign in to comment.