summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-09-18 20:30:14 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-09-18 20:30:14 +0200
commit1448c5bfa5d0977e54670bb8c640ba186bb13167 (patch)
tree50c1cb5fac6bee8738fe69e59ed355150b701cf1 /examples
parentf89744283167a1961fcff512ad48b0eb9b8fcaef (diff)
downloadiced-1448c5bfa5d0977e54670bb8c640ba186bb13167.tar.gz
iced-1448c5bfa5d0977e54670bb8c640ba186bb13167.tar.bz2
iced-1448c5bfa5d0977e54670bb8c640ba186bb13167.zip
Implement some `From` traits for `text_input::Id`
Diffstat (limited to 'examples')
-rw-r--r--examples/multi_window/src/main.rs6
-rw-r--r--examples/todos/Cargo.toml1
-rw-r--r--examples/todos/src/main.rs7
3 files changed, 4 insertions, 10 deletions
diff --git a/examples/multi_window/src/main.rs b/examples/multi_window/src/main.rs
index ab09116e..b43a627a 100644
--- a/examples/multi_window/src/main.rs
+++ b/examples/multi_window/src/main.rs
@@ -25,7 +25,6 @@ struct Window {
scale_input: String,
current_scale: f64,
theme: Theme,
- input_id: iced::widget::text_input::Id,
}
#[derive(Debug, Clone)]
@@ -86,7 +85,7 @@ impl Example {
}
Message::WindowOpened(id) => {
let window = Window::new(self.windows.len() + 1);
- let focus_input = text_input::focus(window.input_id.clone());
+ let focus_input = text_input::focus(format!("input-{id}"));
self.windows.insert(id, window);
@@ -163,7 +162,6 @@ impl Window {
scale_input: "1.0".to_string(),
current_scale: 1.0,
theme: Theme::ALL[count % Theme::ALL.len()].clone(),
- input_id: text_input::Id::unique(),
}
}
@@ -182,7 +180,7 @@ impl Window {
text("Window title:"),
text_input("Window Title", &self.title)
.on_input(move |msg| { Message::TitleChanged(id, msg) })
- .id(self.input_id.clone())
+ .id(format!("input-{id}"))
];
let new_window_button =
diff --git a/examples/todos/Cargo.toml b/examples/todos/Cargo.toml
index 3c62bfbc..0d72be86 100644
--- a/examples/todos/Cargo.toml
+++ b/examples/todos/Cargo.toml
@@ -9,7 +9,6 @@ publish = false
iced.workspace = true
iced.features = ["async-std", "debug"]
-once_cell.workspace = true
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
uuid = { version = "1.0", features = ["v4", "fast-rng", "serde"] }
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs
index a5f7b36a..25e3ead2 100644
--- a/examples/todos/src/main.rs
+++ b/examples/todos/src/main.rs
@@ -6,12 +6,9 @@ use iced::widget::{
use iced::window;
use iced::{Center, Element, Fill, Font, Subscription, Task as Command};
-use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
-static INPUT_ID: Lazy<text_input::Id> = Lazy::new(text_input::Id::unique);
-
pub fn main() -> iced::Result {
#[cfg(not(target_arch = "wasm32"))]
tracing_subscriber::fmt::init();
@@ -85,7 +82,7 @@ impl Todos {
_ => {}
}
- text_input::focus(INPUT_ID.clone())
+ text_input::focus("new-task")
}
Todos::Loaded(state) => {
let mut saved = false;
@@ -198,7 +195,7 @@ impl Todos {
.align_x(Center);
let input = text_input("What needs to be done?", input_value)
- .id(INPUT_ID.clone())
+ .id("new-task")
.on_input(Message::InputChanged)
.on_submit(Message::CreateTask)
.padding(15)