From 9cba92f57f5686f5295cb3430a3787aa3694a1fc Mon Sep 17 00:00:00 2001 From: Andrew Baldwin Date: Mon, 17 Feb 2025 11:15:36 -0800 Subject: Add `is_focused` function that produces an `Operation` to get the focused state of a `focusable` by ID. Add `is_focused` function that produces a `Task` to get the focused state of a `text_input` by ID. --- widget/src/text_input.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'widget') diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs index 697d0d64..a90afd90 100644 --- a/widget/src/text_input.rs +++ b/widget/src/text_input.rs @@ -1481,6 +1481,11 @@ impl From for Id { } } +/// Produces a [`Task`] that returns whether the [`TextInput`] with the given [`Id`] is focused or not. +pub fn is_focused(id: impl Into) -> Task { + task::widget(operation::focusable::is_focused(id.into().into())) +} + /// Produces a [`Task`] that focuses the [`TextInput`] with the given [`Id`]. pub fn focus(id: impl Into) -> Task { task::effect(Action::widget(operation::focusable::focus(id.into().0))) -- cgit