lib/ui: Fix container event

This commit is contained in:
Erik Kundt
2026-01-03 12:59:19 +01:00
parent c9c155bc15
commit e3596efecc
2 changed files with 12 additions and 2 deletions
+10
View File
@@ -323,6 +323,16 @@ impl<M> Ui<M> {
})
}
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<Key> {
if self.has_focus && self.is_area_focused() {
let matches = |&event| {
+2 -2
View File
@@ -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;
}