diff --git a/src/egui.rs b/src/egui.rs index 996f8ae..8578ba8 100644 --- a/src/egui.rs +++ b/src/egui.rs @@ -39,12 +39,15 @@ pub fn check_egui_wants_focus( // that if any of the egui contexts want focus, then it must be the one that the user is // interacting with. let new_wants_focus = windows.iter().any(|window| { - let ctx = contexts.ctx_for_entity_mut(window); - let mut value = ctx.wants_pointer_input() || ctx.wants_keyboard_input(); - if include_hover.0 { - value |= ctx.is_pointer_over_area() + if let Some(ctx) = contexts.try_ctx_for_entity_mut(window) { + let mut value = ctx.wants_pointer_input() || ctx.wants_keyboard_input(); + if include_hover.0 { + value |= ctx.is_pointer_over_area() + } + value + } else { + false } - value }); let new_res = EguiWantsFocus { prev: wants_focus.curr,