mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
Fix: call save when hiding tab, and update when focusing it (#5114)
Fix for a regression in 0.28 * `App::save` will now be called when the web app is hidden (e.g. goes to a background tab) * `App::update` will now be called when the web app is un-hidden (e.g. becomes the foreground tab)
This commit is contained in:
@@ -176,6 +176,12 @@ impl AppRunner {
|
||||
///
|
||||
/// Technically: does either the canvas or the [`TextAgent`] have focus?
|
||||
pub fn has_focus(&self) -> bool {
|
||||
let window = web_sys::window().unwrap();
|
||||
let document = window.document().unwrap();
|
||||
if document.hidden() {
|
||||
return false;
|
||||
}
|
||||
|
||||
super::has_focus(self.canvas()) || self.text_agent.has_focus()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user