Skip to main content

lgui_core/core/component/runtime/
focus.rs

1use super::{input::event_target_ids, *};
2
3impl UiRuntime {
4    pub fn sync_tree_focus(&mut self, tree: &HostTree) -> bool {
5        if !tree.needs_focus_sync() {
6            return false;
7        }
8        let events = self.events.sync_focus_for_tree(tree);
9        if events.is_empty() {
10            return false;
11        }
12        self.mark_component_owners(tree, events.iter().flat_map(event_target_ids));
13        for event in &events {
14            self.dirty.mark_event(event.clone());
15        }
16        apply_events_to_animations(tree, &mut self.animations, events);
17        true
18    }
19
20    pub fn focus_node(&mut self, tree: &HostTree, id: &UiId) -> bool {
21        let events = self.events.focus_node(tree, id);
22        if events.is_empty() {
23            return false;
24        }
25        self.mark_component_owners(tree, events.iter().flat_map(event_target_ids));
26        for event in &events {
27            self.dirty.mark_event(event.clone());
28        }
29        apply_events_to_animations(tree, &mut self.animations, events);
30        true
31    }
32}