mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Mark all keys as up if the app loses focus (#5743)
In Rerun, pressing `Cmd+S` brings up a save dialog using `rfd`, but we get not key-up event for the `S` key (in winit). This leads to `S` being mistakenly marked as down when we switch back to the app. This PR takes the safe route and marks all keys as up when an egui app loses focus. * Tested with https://github.com/rerun-io/rerun/pull/9103
This commit is contained in:
@@ -362,6 +362,14 @@ impl InputState {
|
||||
Event::Zoom(factor) => {
|
||||
zoom_factor_delta *= *factor;
|
||||
}
|
||||
Event::WindowFocused(false) => {
|
||||
// Example: pressing `Cmd+S` brings up a save-dialog (e.g. using rfd),
|
||||
// but we get no key-up event for the `S` key (in winit).
|
||||
// This leads to `S` being mistakenly marked as down when we switch back to the app.
|
||||
// So we take the safe route and just clear all the keys and modifiers when
|
||||
// the app loses focus.
|
||||
keys_down.clear();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user