Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
lib/ui: Fix container event
Erik Kundt committed 3 months ago
commit e3596efecc2e4e1277773bc25b81c072c4c253f7
parent c9c155b
2 files changed +12 -2
modified src/ui/im.rs
@@ -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| {
modified 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;
        }