Windows Performing an event when alt-F4 or Windows 'x' is clicked

quattj

Member
Is it possible to perform an event when either alt-F4 or the Windows 'x' button is clicked to close the window? I am making an editor, and I do not want these to close the editor before confirming that changes have been saved.

I currently have a confirmation dialog that pops up if ESC is used to close it, and I'd like to apply that same dialog to alt-F4 and 'x'
 

SoapSud39

Member
If you use the Game End event (under Other in Add Event), you can make it do something before closing (like a quick auto-save). I'm not sure if there's actually a way to 'go back' when you reach the Game End event (like when you close the window or alt-F4).
 

NightFrost

Member
Game End event is what you're looking for. But I'm not sure if GM will delay closure when you pop up a windows dialog, I've never tried so you'll have to see for yourself. You can abuse show_question for that. I say abuse, as it is chiefly meant for debugging.

Note that if you're planning a mobile target, this won't work as they mostly don't notify programs of shutdown, so Game End does nothing on them.
 
Top