diff --git a/runtime/src/widget/selector.rs b/runtime/src/widget/selector.rs index d6fc6f9a..fa7ff749 100644 --- a/runtime/src/widget/selector.rs +++ b/runtime/src/widget/selector.rs @@ -3,6 +3,8 @@ pub use iced_selector::Selector; pub use iced_selector::target::{Bounded, Match, Target, Text}; +use crate::core::Rectangle; + use crate::Task; use crate::core::widget; use crate::task; @@ -16,3 +18,13 @@ pub fn find_by_id(id: impl Into) -> Task> { pub fn find_by_text(text: impl Into) -> Task> { task::widget(Selector::find(text.into())) } + +/// Finds the visible bounds of the first [`Selector`] target. +pub fn visible_bounds(selector: S) -> Task> +where + S: Selector + Send + 'static, + S::Output: Bounded + Clone + Send + 'static, +{ + task::widget(selector.find()) + .map(|target| target.as_ref().and_then(Bounded::visible_bounds)) +}