Allow converting from widget-specific IDs to generic ID
This commit is contained in:
parent
23299a555f
commit
44aba47b0e
2 changed files with 12 additions and 0 deletions
|
|
@ -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`]
|
/// Produces a [`Command`] that snaps the [`Scrollable`] with the given [`Id`]
|
||||||
/// to the provided `percentage`.
|
/// to the provided `percentage`.
|
||||||
pub fn snap_to<Message: 'static>(id: Id, percentage: f32) -> Command<Message> {
|
pub fn snap_to<Message: 'static>(id: Id, percentage: f32) -> Command<Message> {
|
||||||
|
|
|
||||||
|
|
@ -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`].
|
/// Produces a [`Command`] that focuses the [`TextInput`] with the given [`Id`].
|
||||||
pub fn focus<Message: 'static>(id: Id) -> Command<Message> {
|
pub fn focus<Message: 'static>(id: Id) -> Command<Message> {
|
||||||
Command::widget(operation::focusable::focus(id.0))
|
Command::widget(operation::focusable::focus(id.0))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue