diff --git a/egui/src/main.rs b/egui/src/main.rs index 2a49d0f..6d65d81 100644 --- a/egui/src/main.rs +++ b/egui/src/main.rs @@ -426,6 +426,9 @@ struct UiState { query: String, search_results: Vec, + + was_focused: bool, + skipped_first_focus: bool, } #[derive(Debug)] @@ -587,6 +590,16 @@ fn main_ui( .and_then(|()| requests.send(Command::LoadFirstPage)); }; + ui.input(|i| { + if !state.was_focused && i.focused && state.skipped_first_focus { + refresh(); + } + if i.focused { + state.skipped_first_focus = true; + } + state.was_focused = i.focused; + }); + if let Some(ref e) = state.fatal_error { ui.label(format!("Fatal error: {e:?}")); return;