pub fn hit_test_target<A>(
tree: &ElementTree<A>,
engine: &HitTestEngine,
pos: Point,
clip: Option<ClipShape>,
) -> Option<ElementId>Expand description
Returns the topmost retained widget containing a global logical point.
Overlay hit regions are searched first, in reverse child/paint order. The
normal pass then requires the point to lie inside every ancestor bound and
clip, visits later children first, and returns widgets only. clip, when
present, is an additional global clip. The engine parameter is retained for
API compatibility; tree traversal performs the test and records per-element
hit-test diagnostics. Missing roots or layout yield None.
ยงExamples
use ailloli_ui_core::{Point, Rect};
use ailloli_ui_runtime::{element::{ElementKind, ElementTree}, input::{hit_test_target, HitTestEngine}, layout::LayoutResult};
let mut tree = ElementTree::<()>::new();
let root = tree.create_element(ElementKind::Empty, None, None);
let mut layout = LayoutResult::empty();
layout.paint_bounds = Rect::new(0.0, 0.0, 20.0, 20.0);
tree.get_mut(root).unwrap().layout = Some(layout);
// Empty retained nodes are traversed but are not event targets.
assert_eq!(hit_test_target(&tree, &HitTestEngine, Point::new(5.0, 5.0), None), None);