Simplify WindowOpened message handler in multi_window example

This commit is contained in:
Héctor Ramón Jiménez 2024-06-14 03:11:07 +02:00
parent 88b9384402
commit 20945e3f90
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -87,13 +87,12 @@ impl multi_window::Application for Example {
.map(Message::WindowOpened)
}
Message::WindowOpened(id) => {
self.windows.insert(id, Window::new(self.windows.len() + 1));
let window = Window::new(self.windows.len() + 1);
let focus_input = text_input::focus(window.input_id.clone());
if let Some(window) = self.windows.get(&id) {
text_input::focus(window.input_id.clone())
} else {
Task::none()
}
self.windows.insert(id, window);
focus_input
}
Message::WindowClosed(id) => {
self.windows.remove(&id);