Any event for when user presses "X" on window?
by Joe Rossi · in Torque Game Builder · 01/11/2008 (11:32 am) · 2 replies
Is there an easy way to catch when the user presses the "X" button on the game window? I see the editor catches this and prompts the user to save. I'm hoping to do something similar in my game, hopefully without having to hack into the C++ platform code.
#2
in platformWin32/winWindow.cc
around line 8 or 900ish
I haven't looked at the Mac or Linux platform code, I'll cross that bridge when I get there (unless GG can change the sources to include this event for games as well..) but at least I got it working for windows.
So comment that #ifdef, create an onClosePressed function in your game, you can catch the X. This function gets called before onExit does.
01/11/2008 (11:03 pm)
Thanks Phillip. I was able to figured it out, but I had to dig into the C++ code. It seems that the tools have a different event that is only compiled into the TGB editor, but not the games.in platformWin32/winWindow.cc
around line 8 or 900ish
#ifdef TORQUE_TOOLS
// Catch Close button press event [1/5/2007 justind]
case SC_CLOSE:
if (Con::isFunction("onClosePressed"))
{
Con::executef( 1, "onClosePressed" );
return 0;
}
break;
#endif // TORQUE_TOOLSI haven't looked at the Mac or Linux platform code, I'll cross that bridge when I get there (unless GG can change the sources to include this event for games as well..) but at least I got it working for windows.
So comment that #ifdef, create an onClosePressed function in your game, you can catch the X. This function gets called before onExit does.
Associate Phillip O'Shea
Violent Tulip