Skip to content

Commit

Permalink
Respect Window.AllowAltF4 For SDLGamePlatform (MonoGame#8248)
Browse files Browse the repository at this point in the history
When checking the exit condition of `_isExiting > 0` an additional check is now made to determine if the exit should occur.  This check for the ALT+F4 keyboard combination, and if found, returns the state of `Window.AllowAltF4`; otherwise it return `true`.
  • Loading branch information
AristurtleDev authored May 18, 2024
1 parent 4c77896 commit d26be94
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion MonoGame.Framework/Platform/SDL/SDLGamePlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,27 @@ public override void RunLoop()
Threading.Run();
GraphicsDevice.DisposeContexts();

if (_isExiting > 0)
if (_isExiting > 0 && ShouldExit())
{
break;
}
else
{
_isExiting = 0;
}
}
}

private bool ShouldExit()
{
if(_keys.Contains(Keys.F4) && (_keys.Contains(Keys.LeftAlt) || _keys.Contains(Keys.RightAlt)))
{
return Window.AllowAltF4;
}

return true;
}

private void SdlRunLoop()
{
Sdl.Event ev;
Expand Down

0 comments on commit d26be94

Please sign in to comment.