(&self)
| 73 | } |
| 74 | |
| 75 | pub fn is_focused(&self) -> bool { |
| 76 | let dominated_by_active_descendant = |node_id| { |
| 77 | self.tree_state |
| 78 | .node_by_id(node_id) |
| 79 | .and_then(|node| node.active_descendant()) |
| 80 | .is_some() |
| 81 | }; |
| 82 | match self.tree_state.focus_id() { |
| 83 | Some(focus_id) if focus_id == self.id() => !dominated_by_active_descendant(focus_id), |
| 84 | Some(focus_id) => self |
| 85 | .tree_state |
| 86 | .node_by_id(focus_id) |
| 87 | .and_then(|focused| focused.active_descendant()) |
| 88 | .is_some_and(|active_descendant| active_descendant.id() == self.id()), |
| 89 | None => false, |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | pub fn is_focused_in_tree(&self) -> bool { |
| 94 | self.tree_state.focus == self.id() |
no test coverage detected