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

Clear all keys and modifies on focus change (#2933)

It is very easy for keys to become stuck when we alt-tab,
or a save-dialog opens by Ctrl+S, etc.
Therefore we new clear all the modifiers and down keys to avoid that.
This commit is contained in:
Emil Ernerfeldt
2023-04-19 15:27:51 +02:00
committed by GitHub
parent ede3ded977
commit d1af798a9b
7 changed files with 50 additions and 16 deletions

View File

@@ -927,6 +927,8 @@ pub struct WindowInfo {
pub maximized: bool,
/// Is the window focused and able to receive input?
///
/// This should be the same as [`egui::InputState::focused`].
pub focused: bool,
/// Window inner size in egui points (logical pixels).

View File

@@ -31,9 +31,10 @@ impl WebInput {
}
}
pub fn on_web_page_focus_change(&mut self, has_focus: bool) {
pub fn on_web_page_focus_change(&mut self, focused: bool) {
self.raw.modifiers = egui::Modifiers::default();
self.raw.has_focus = has_focus;
self.raw.focused = focused;
self.raw.events.push(egui::Event::WindowFocused(focused));
self.latest_touch_pos = None;
self.latest_touch_pos_id = None;
}