summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorLibravatar mtkennerly <mtkennerly@gmail.com>2022-11-11 08:44:10 +0800
committerLibravatar mtkennerly <mtkennerly@gmail.com>2022-11-11 08:44:10 +0800
commit44aba47b0e67ce3cf1d5e8a79768e8fe996f5580 (patch)
tree2fb85fb14b88963a53a9bc4104be6c5cfe3ac87c /native
parent23299a555f8b7e908a6a14915307792a7cf97b9a (diff)
downloadiced-44aba47b0e67ce3cf1d5e8a79768e8fe996f5580.tar.gz
iced-44aba47b0e67ce3cf1d5e8a79768e8fe996f5580.tar.bz2
iced-44aba47b0e67ce3cf1d5e8a79768e8fe996f5580.zip
Allow converting from widget-specific IDs to generic ID
Diffstat (limited to '')
-rw-r--r--native/src/widget/scrollable.rs6
-rw-r--r--native/src/widget/text_input.rs6
2 files changed, 12 insertions, 0 deletions
diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs
index b257cbe5..32ec6eb3 100644
--- a/native/src/widget/scrollable.rs
+++ b/native/src/widget/scrollable.rs
@@ -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> {
diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs
index 2315b05a..e57f41ea 100644
--- a/native/src/widget/text_input.rs
+++ b/native/src/widget/text_input.rs
@@ -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))