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:
Emil Ernerfeldt 2025-02-25 14:05:35 +01:00 committed by GitHub
parent 27e7303ebe
commit 6a96612cb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 0 deletions

View File

@ -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();
}
_ => {}
}
}