mirror of
https://github.com/emilk/egui.git
synced 2026-09-03 07:10:04 -04:00
eframe web: Better panic handling (#2942)
* Refactor: remove extra store of events * Remove unnecessary extra function * Refactor: simplify event registering * Store panic summary * egui_demo_app: move web-part to own module * index.html: await * Properly unsubscribe from events on panic * Better error handling * Demo app html: hide the wasm canvas and show an error message on panic * egui_demo_app: add panic button to test panic response on web * fix typo * Use a constructor to create WebHandle * Refactor: less use of locks in the interfaces * More consistent naming
This commit is contained in:
@@ -108,11 +108,10 @@ impl BackendPanel {
|
||||
ui.ctx().set_debug_on_hover(debug_on_hover);
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[cfg(feature = "web_screen-reader")]
|
||||
{
|
||||
ui.separator();
|
||||
let mut screen_reader = ui.ctx().options(|o| o.screen_reader);
|
||||
ui.checkbox(&mut screen_reader, "🔈 Screen reader").on_hover_text("Experimental feature: checking this will turn on the screen reader on supported platforms");
|
||||
ui.ctx().options_mut(|o| o.screen_reader = screen_reader);
|
||||
@@ -125,6 +124,15 @@ impl BackendPanel {
|
||||
frame.close();
|
||||
}
|
||||
}
|
||||
|
||||
if cfg!(debug_assertions) && cfg!(target_arch = "wasm32") {
|
||||
ui.separator();
|
||||
// For testing panic handling on web:
|
||||
#[allow(clippy::manual_assert)]
|
||||
if ui.button("panic!()").clicked() {
|
||||
panic!("intentional panic!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn integration_ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) {
|
||||
|
||||
Reference in New Issue
Block a user