Skip to content

Commit

Permalink
Fixed panic when egui fails to return window (#84)
Browse files Browse the repository at this point in the history
Co-authored-by: Mat Stevenson <mat@offaxis.dev>
  • Loading branch information
Mat-Stevenson-Simworx and matstey authored Oct 23, 2024
1 parent 25144d9 commit d5495dd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/egui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d5495dd

Please sign in to comment.