Skip to content

Commit

Permalink
Implement find_focus() for text_input
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonie Theobald committed Nov 5, 2024
1 parent 42a2cb6 commit eb79224
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions widget/src/text_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,12 @@ impl From<Id> for widget::Id {
}
}

impl From<widget::Id> 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)
Expand All @@ -1283,6 +1289,11 @@ pub fn focus<T>(id: impl Into<Id>) -> Task<T> {
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<impl Into<Id>> {
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<T>(id: impl Into<Id>) -> Task<T> {
Expand Down

0 comments on commit eb79224

Please sign in to comment.