Focus PhotoCraft when unsaved-close prompt appears (#547)

This commit is contained in:
Sean Lavery 2026-10-07 04:07:00 -07:00 committed by GitHub
parent 45d0f4ad93
commit 395a52e7f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -86,6 +86,7 @@ pub fn guard_window_close(app: &mut PhotocraftApp, ctx: &egui::Context) {
}
if intercept(app, EXIT, &Value::Null) {
ctx.send_viewport_cmd(egui::ViewportCommand::CancelClose);
ctx.send_viewport_cmd(egui::ViewportCommand::Focus);
}
}
@ -383,7 +384,10 @@ mod tests {
input.viewports.insert(egui::ViewportId::ROOT, info);
let mut out = egui::Context::default().run_ui(input, |ui| guard_window_close(app, ui.ctx()));
out.textures_delta.clear();
out.viewport_output[&egui::ViewportId::ROOT].commands.iter().any(|c| matches!(c, egui::ViewportCommand::CancelClose))
let commands = &out.viewport_output[&egui::ViewportId::ROOT].commands;
let cancelled = commands.iter().any(|c| matches!(c, egui::ViewportCommand::CancelClose));
assert_eq!(commands.iter().any(|c| matches!(c, egui::ViewportCommand::Focus)), cancelled);
cancelled
}
#[test]