[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
1 changed files with 14 additions and 0 deletions
|
@ -109,6 +109,20 @@ namespace OpenTK.Platform
|
|||
protected void OnFocusedChanged(EventArgs 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)
|
||||
|
|
Loading…
Reference in a new issue