Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement find_focused() for text_input #2664

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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