euv_ui/hook/use_hover/struct.rs
1use super::*;
2
3/// Reactive state for a hover watcher.
4///
5/// The handle carries the element the hook watches — a [`NodeRef`] the
6/// caller attaches to its own markup — and the signal that reports
7/// whether the pointer is currently over it.
8///
9/// The watcher listens on the document rather than on the element
10/// itself, for the same reason the click-outside watcher does: the
11/// element does not exist while the first render is being built, and a
12/// document listener can then ask whether the pointer's node sits
13/// inside the watched element.
14#[derive(Clone, CustomDebug, Data)]
15pub struct UseHover {
16 /// The element the hook watches.
17 ///
18 /// Attach it to the caller's markup with the `ref:` attribute.
19 pub target: NodeRef<Element>,
20 /// Whether the pointer is currently over the watched element.
21 #[get(type(copy))]
22 pub hovered: Signal<bool>,
23 /// The teardown that removes the document listeners.
24 #[get(pub(crate))]
25 #[debug(skip)]
26 pub(crate) teardown: Teardown,
27}