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:
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user