mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-09 13:00:35 +00:00
[Platform] Raise KeyUp events on focus lost
This ensures that no keys are stuck in pressed state when the user switches away from the application window.
This commit is contained in:
parent
86146f54d5
commit
ab29797079
|
@ -109,6 +109,20 @@ namespace OpenTK.Platform
|
||||||
protected void OnFocusedChanged(EventArgs e)
|
protected void OnFocusedChanged(EventArgs e)
|
||||||
{
|
{
|
||||||
FocusedChanged(this, e);
|
FocusedChanged(this, e);
|
||||||
|
|
||||||
|
if (!Focused)
|
||||||
|
{
|
||||||
|
// Clear keyboard state, otherwise KeyUp
|
||||||
|
// events may be missed resulting in stuck
|
||||||
|
// keys.
|
||||||
|
for (Key key = 0; key < Key.LastKey; key++)
|
||||||
|
{
|
||||||
|
if (KeyboardState[key])
|
||||||
|
{
|
||||||
|
OnKeyUp(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnWindowBorderChanged(EventArgs e)
|
protected void OnWindowBorderChanged(EventArgs e)
|
||||||
|
|
Loading…
Reference in a new issue