mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-10-31 00:40:57 +08:00
lib/ui: Fix container event
This commit is contained in:
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user