From 274ac38b3f6a5d447f238be298cdb3227a1b8679 Mon Sep 17 00:00:00 2001 From: Leonie Theobald Date: Tue, 5 Nov 2024 14:06:36 +0100 Subject: [PATCH] Implement find_focused() for text_input --- widget/src/text_input.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs index ff41377946..4856da03a9 100644 --- a/widget/src/text_input.rs +++ b/widget/src/text_input.rs @@ -1266,6 +1266,12 @@ impl From for widget::Id { } } +impl From for Id { + fn from(id: widget::Id) -> Self { + Id(id) + } +} + impl From<&'static str> for Id { fn from(id: &'static str) -> Self { Self::new(id) @@ -1283,6 +1289,11 @@ pub fn focus(id: impl Into) -> Task { task::effect(Action::widget(operation::focusable::focus(id.into().0))) } +/// Produces a [`Task`] that searches for a focused [`TextInput`] and returns the [`Id`] on success +pub fn find_focused() -> Task> { + task::widget(operation::focusable::find_focused()) +} + /// Produces a [`Task`] that moves the cursor of the [`TextInput`] with the given [`Id`] to the /// end. pub fn move_cursor_to_end(id: impl Into) -> Task {