euv_ui/hook/use_click_outside/struct.rs
1use super::*;
2
3/// Reactive state for a click-outside watcher.
4///
5/// The handle carries the element the hook watches — a [`NodeRef`]
6/// the caller attaches to its own markup — and the signal that is
7/// raised when a pointer press lands outside that element.
8///
9/// The watcher listens on the document rather than on the element
10/// itself. That is deliberate: the element does not exist while the
11/// first render is being built, so a listener attached to it would
12/// have nothing to attach to, and a document listener sees the press
13/// either way and can then ask whether the pressed node sits inside
14/// the watched element.
15#[derive(Clone, CustomDebug, Data)]
16pub struct UseClickOutside {
17 /// The element the hook watches.
18 ///
19 /// Attach it to the caller's markup with the `ref:` attribute.
20 pub target: NodeRef<Element>,
21 /// Raised when a press landed outside the watched element.
22 #[get(type(copy))]
23 pub triggered: Signal<bool>,
24 /// The teardown that removes the document listener.
25 #[get(pub(crate))]
26 #[debug(skip)]
27 pub(crate) teardown: Teardown,
28}