Try to find text targets in tester::recorder

This commit is contained in:
Héctor Ramón Jiménez 2025-08-23 06:37:02 +02:00
parent 81d1eda7fe
commit 1923d1db1e
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
5 changed files with 245 additions and 59 deletions

View file

@ -8,6 +8,7 @@ mod find;
pub use find::{Find, FindAll};
pub use target::Target;
use crate::core::Point;
use crate::core::widget::Id;
pub trait Selector {
@ -116,6 +117,21 @@ impl Selector for Id {
}
}
impl Selector for Point {
type Output = target::Match;
fn select(&mut self, target: Target<'_>) -> Option<Self::Output> {
target
.visible_bounds()
.is_some_and(|visible_bounds| visible_bounds.contains(*self))
.then(|| target::Match::from_target(target))
}
fn description(&self) -> String {
format!("bounds contains {:?}", self)
}
}
impl<F, T> Selector for F
where
F: FnMut(Target<'_>) -> Option<T>,