Allow closing the window from user code

This commit is contained in:
Richard 2022-07-26 16:46:12 -03:00 committed by bungoboingo
parent 3d901d5f1f
commit 35331d0a41
4 changed files with 76 additions and 23 deletions

View file

@ -189,6 +189,17 @@ where
proxy: &EventLoopProxy<Event<A::Message>>,
) {
let new_windows = application.windows();
// Check for windows to close
for window_id in windows.keys() {
if !new_windows.iter().any(|(id, _)| id == window_id) {
proxy
.send_event(Event::CloseWindow(*window_id))
.expect("Failed to send message");
}
}
// Check for windows to spawn
for (id, settings) in new_windows {
if !windows.contains_key(&id) {
proxy