1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 06:10:06 -04:00

eframe: allow aborting an exit event (#1038)

This commit is contained in:
Erlend Walstad
2022-01-17 18:45:09 +01:00
committed by GitHub
parent 87ac7446da
commit ab77099781
4 changed files with 79 additions and 4 deletions

View File

@@ -240,7 +240,11 @@ impl EpiIntegration {
self.app
.setup(&self.egui_ctx, &self.frame, self.persistence.storage());
let app_output = self.frame.take_app_output();
self.quit |= app_output.quit;
if app_output.quit {
self.quit = self.app.on_exit_event();
}
crate::epi::handle_app_output(window, self.egui_ctx.pixels_per_point(), app_output);
}
@@ -260,7 +264,12 @@ impl EpiIntegration {
pub fn on_event(&mut self, event: &winit::event::WindowEvent<'_>) {
use winit::event::WindowEvent;
self.quit |= matches!(event, WindowEvent::CloseRequested | WindowEvent::Destroyed);
if *event == WindowEvent::CloseRequested {
self.quit = self.app.on_exit_event();
} else if *event == WindowEvent::Destroyed {
self.quit = true;
}
self.egui_winit.on_event(&self.egui_ctx, event);
}
@@ -282,7 +291,10 @@ impl EpiIntegration {
.handle_output(window, &self.egui_ctx, egui_output);
let app_output = self.frame.take_app_output();
self.quit |= app_output.quit;
if app_output.quit {
self.quit = self.app.on_exit_event();
}
crate::epi::handle_app_output(window, self.egui_ctx.pixels_per_point(), app_output);