From 37f77ec241a08f0df29e5f247cb66a7383e9e607 Mon Sep 17 00:00:00 2001 From: Huon Imberger Date: Tue, 19 Dec 2023 18:52:45 +1100 Subject: [PATCH] Update comment about egui contexts and windows --- src/egui.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/egui.rs b/src/egui.rs index 22dfb89..8dffe8c 100644 --- a/src/egui.rs +++ b/src/egui.rs @@ -22,9 +22,10 @@ pub fn check_egui_wants_focus( mut wants_focus: ResMut, windows: Query>, ) { - // If _any_ egui context wants focus, then we treat that as 'egui wants focus', because only - // one window can receive input events at a time anyway. In other words, there's no need to - // match the egui context with the window currently receiving events. + // The window that the user is interacting with and the window that contains the egui context + // that the user is interacting with are always going to be the same. Therefore, we can assume + // 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_window_mut(window); ctx.wants_pointer_input() || ctx.wants_keyboard_input()