Added method to InputState to clear pressed keys, mods, and mouse. Call method on window focus loss.

This commit is contained in:
Ac5000 authored and meehl committed 2026-02-28 10:23:56 +01:00
1 parent 9d33a7704c
commit 966363a859
2 files changed
+12

No files matched your search

+8
View File
@@ -77,6 +77,14 @@ impl InputState {
pub fn set_mouse_pos(&mut self, pos: LogicalPoint<f32>) {
self.cursor_pos = pos;
}
/// Clears all pressed keys, buttons, and modifier states. Used when the
/// application loses focus to avoid keys being "stuck" on/pressed.
pub fn clear_pressed(&mut self) {
self.keys_pressed.clear();
self.mouse_pressed.clear();
self.key_modifiers = ModifiersState::empty();
}
}
/// Attempts to convert the provided string `s` to a [KeyCode].