Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect Window.AllowAltF4 For SDLGamePlatform #8248

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

AristurtleDev
Copy link
Contributor

Description

Currently Window.AllowAltF4 is not respected for SDLGamePlatform. No matter the property setting ALT+F4 will close the window.

This PR adds the check for Alt+F4 during the exit check in the platform loop and handles exiting based on the keyboard key combination and the Window.AllowAltF4 property. If the keyboard combination was not pressed, then it falls back to the default behavior of allowing the exit to occur.

Notes

Press Alt+F4 will trigger SDL.EventType.Quit

case Sdl.EventType.Quit:
_isExiting++;
break;

However, Alt+F4 can also trigger Sdl.Window.EventId.Close

case Sdl.Window.EventId.Close:
_isExiting++;
break;

It is inconsistent on which of these events is triggered first. Regardless, when both events are triggered, they _keys collection does not contain both the Keys.LeftAlt/Keys.RightAlt and the Keys.F4 due to the events firing before the keyboard update is performed.

Due to these reasons, this is why the check was moved into the platform loop and made during the _isExiting check.

AristurtleDev and others added 2 commits March 20, 2024 23:19
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant