Allow converting from widget-specific IDs to generic ID

This commit is contained in:
mtkennerly 2022-11-11 08:44:10 +08:00
parent 23299a555f
commit 44aba47b0e
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
2 changed files with 12 additions and 0 deletions

View file

@ -334,6 +334,12 @@ impl Id {
}
}
impl From<Id> for widget::Id {
fn from(id: Id) -> Self {
id.0
}
}
/// Produces a [`Command`] that snaps the [`Scrollable`] with the given [`Id`]
/// to the provided `percentage`.
pub fn snap_to<Message: 'static>(id: Id, percentage: f32) -> Command<Message> {

View file

@ -332,6 +332,12 @@ impl Id {
}
}
impl From<Id> for widget::Id {
fn from(id: Id) -> Self {
id.0
}
}
/// Produces a [`Command`] that focuses the [`TextInput`] with the given [`Id`].
pub fn focus<Message: 'static>(id: Id) -> Command<Message> {
Command::widget(operation::focusable::focus(id.0))