Skip to main content

euv_core/scene/focus/
impl.rs

1use super::*;
2
3/// Safe inspection helpers for `FocusManager`.
4impl FocusManager {
5    /// Returns the currently focused node if any.
6    ///
7    /// # Arguments
8    ///
9    /// - `&Self` - Focus manager reference.
10    ///
11    /// # Returns
12    ///
13    /// - `Option<NodeId>` - Focused node identifier.
14    #[must_use]
15    pub fn focused_node(&self) -> Option<NodeId> {
16        let Self { focused, .. } = *self;
17        focused
18    }
19
20    /// Returns the currently hovered node if any.
21    ///
22    /// # Arguments
23    ///
24    /// - `&Self` - Focus manager reference.
25    ///
26    /// # Returns
27    ///
28    /// - `Option<NodeId>` - Hovered node identifier.
29    #[must_use]
30    pub fn hovered_node(&self) -> Option<NodeId> {
31        let Self { hovered, .. } = *self;
32        hovered
33    }
34
35    /// Returns the currently pressed node if any.
36    ///
37    /// # Arguments
38    ///
39    /// - `&Self` - Focus manager reference.
40    ///
41    /// # Returns
42    ///
43    /// - `Option<NodeId>` - Pressed node identifier.
44    #[must_use]
45    pub fn pressed_node(&self) -> Option<NodeId> {
46        let Self { pressed, .. } = *self;
47        pressed
48    }
49}