Game Development Community

Key binding problem in ALT F4 keys...

by Raja John · in Torque Game Builder · 12/17/2008 (1:40 am) · 6 replies

In many games, while we are in game window press ALT F4, it shows a GUI (Are You Sure?). Is this possible in TGB?

In my game i wish to push a GUI control after pressing ALT F4 keys as below

in game.cs (under function startGame(%level))

moveMap.bind("keyboard", "alt f4", "finishc");

and my finishc function is..

function finishc()
{
Canvas.pushDialog(endGUI);
}

But it is not working for me. any mistake in my keybind?

#1
12/17/2008 (9:36 am)
Did you try removing the quotes around keyboard and finishc?
#2
12/17/2008 (10:28 am)
Alt F4 is a Windows OS key to close the application, often in an ungraceful manner.
#3
12/17/2008 (10:54 am)
That begs the question then...

Is there a way to override that in TGB similar to other applications that seem to catch alt F4 before allowing Windows to force the app to close?
#4
12/17/2008 (11:22 am)
Most likely during shutdown. Of course, you could program around it with the Pro source. That way you would be able to stop people from accessing Task Manager with CTRL-ALT-DEL and killing your application as well.
#5
12/17/2008 (11:25 pm)
Thank you David,

If we press Alt + F4 key suddenly the windows will close my game application, Before closing the application I want push a GUI screen "Do you want to Quit" with "YES or NO" options, is it possible in TGB? if so... please tell me the solution. I am having TGB 1.7.4 pro.
#6
12/18/2008 (6:31 am)
I don't know since I haven't done anything with the startup and shutdown processes in Torque. My best guess from a cursory glance at the source (which may be completely incorrect) would be to look in the platform/gameInterface.cc and mainShutdown(). But you might (and again, this was only after a cursory glance) want to capture and report via platformWin32/winWindow.cc. There is a lot of work done in there for working with keystrokes associated with the window as well as the cleanup in shutdown().

Those would be starting places to look. There is probably much better places, though those are the two that stuck out to me. Since I haven't dealt with this, though, I may be leading you very far astray!