Introduce selector flag and decouple iced_widget from iced_runtime

This commit is contained in:
Héctor Ramón Jiménez 2025-08-23 05:15:57 +02:00
parent 34a42b5ad4
commit 81d1eda7fe
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
22 changed files with 118 additions and 67 deletions

View file

@ -66,6 +66,40 @@ impl Selector for &str {
}
}
impl Selector for String {
type Output = target::Text;
fn select(&mut self, target: Target<'_>) -> Option<Self::Output> {
match target {
Target::TextInput {
id,
bounds,
visible_bounds,
state,
} if state.text() == *self => Some(target::Text::Input {
id: id.cloned(),
bounds,
visible_bounds,
}),
Target::Text {
id,
bounds,
visible_bounds,
content,
} if content == *self => Some(target::Text::Raw {
id: id.cloned(),
bounds,
visible_bounds,
}),
_ => None,
}
}
fn description(&self) -> String {
format!("text == \"{}\"", self.escape_default())
}
}
impl Selector for Id {
type Output = target::Match;