MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / find_element_tap_target

Function find_element_tap_target

packages/server/src/main/tap_target.rs:52–77  ·  view source on GitHub ↗
(
    snapshot: &Value,
    selector: &ElementSelector,
)

Source from the content-addressed store, hash-verified

50}
51
52fn find_element_tap_target(
53 snapshot: &Value,
54 selector: &ElementSelector,
55) -> Option<ElementTapTarget> {
56 let roots = snapshot.get("roots")?.as_array()?;
57 let mut matches = Vec::new();
58 for root in roots {
59 let (root_width, root_height) = element_size(root)?;
60 collect_matching_elements(root, selector, root_width, root_height, &mut matches);
61 }
62 let target = if let Some(index) = selector.index {
63 matches.into_iter().nth(index)
64 } else {
65 matches
66 .into_iter()
67 .max_by_key(|target| is_actionable_element(target.node) as u8)
68 };
69 target.and_then(|target| {
70 element_center(target.node).map(|(x, y)| ElementTapTarget {
71 x,
72 y,
73 root_width: target.root_width,
74 root_height: target.root_height,
75 })
76 })
77}
78
79struct MatchedElement<'a> {
80 node: &'a Value,

Callers 1

resolve_tap_targetFunction · 0.85

Calls 5

element_sizeFunction · 0.85
is_actionable_elementFunction · 0.85
element_centerFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected