1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 05:40:03 -04:00

Fix focus problems on web (#4745)

* Closes https://github.com/emilk/egui/issues/4743
* Related to https://github.com/emilk/egui/issues/4569
This commit is contained in:
Emil Ernerfeldt
2024-07-01 10:38:54 +02:00
committed by GitHub
parent 31716d787e
commit d271718065
3 changed files with 43 additions and 18 deletions

View File

@@ -103,17 +103,8 @@ fn install_blur_focus(runner_ref: &WebRunner, target: &EventTarget) -> Result<()
// so we also poll the focus state each frame in `AppRunner::logic`.
for event_name in ["blur", "focus"] {
let closure = move |_event: web_sys::MouseEvent, runner: &mut AppRunner| {
// log::debug!("{event_name:?}");
let has_focus = event_name == "focus";
if !has_focus {
// We lost focus - good idea to save
runner.save();
}
runner.input.set_focus(has_focus);
runner.egui_ctx().request_repaint();
// log::debug!("{} {event_name:?}", runner.canvas().id());
runner.update_focus();
};
runner_ref.add_event_listener(target, event_name, closure)?;