Simplify WindowOpened message handler in multi_window example
This commit is contained in:
parent
88b9384402
commit
20945e3f90
1 changed files with 5 additions and 6 deletions
|
|
@ -87,13 +87,12 @@ impl multi_window::Application for Example {
|
||||||
.map(Message::WindowOpened)
|
.map(Message::WindowOpened)
|
||||||
}
|
}
|
||||||
Message::WindowOpened(id) => {
|
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) {
|
self.windows.insert(id, window);
|
||||||
text_input::focus(window.input_id.clone())
|
|
||||||
} else {
|
focus_input
|
||||||
Task::none()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Message::WindowClosed(id) => {
|
Message::WindowClosed(id) => {
|
||||||
self.windows.remove(&id);
|
self.windows.remove(&id);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue