From e3596efecc2e4e1277773bc25b81c072c4c253f7 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Wed, 31 Dec 2025 00:17:16 +0100 Subject: [PATCH] lib/ui: Fix container event --- src/ui/im.rs | 10 ++++++++++ src/ui/im/widget.rs | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ui/im.rs b/src/ui/im.rs index 9bc94322..3324cef9 100644 --- a/src/ui/im.rs +++ b/src/ui/im.rs @@ -323,6 +323,16 @@ impl Ui { }) } + pub fn has_global_input(&mut self, f: impl Fn(Key) -> bool) -> bool { + self.has_focus + && self.ctx.inputs.iter().any(|event| { + if let Event::Key(key) = event { + return f(*key); + } + false + }) + } + pub fn get_input(&mut self, f: impl Fn(Key) -> bool) -> Option { if self.has_focus && self.is_area_focused() { let matches = |&event| { diff --git a/src/ui/im/widget.rs b/src/ui/im/widget.rs index b0d4b0e5..89965b8e 100644 --- a/src/ui/im/widget.rs +++ b/src/ui/im/widget.rs @@ -135,11 +135,11 @@ impl<'a> Container<'a> { len: self.len, }; - if ui.has_input(|key| key == Key::Tab) { + if ui.has_global_input(|key| key == Key::Tab) { state.focus_next(); response.changed = true; } - if ui.has_input(|key| key == Key::BackTab) { + if ui.has_global_input(|key| key == Key::BackTab) { state.focus_prev(); response.changed = true; }