Game Development Community

ALT + F4 is not call a function...

by mohanmartin · in Technical Issues · 11/01/2008 (4:18 am) · 6 replies

My function for quit conformation is

function finish()
{
Canvas.pushDialog(finishGUI);
}

my hot keys function is

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

its not call function "finish", otherwise game window closed immediately. How could i solve this?...

#1
11/01/2008 (4:26 am)
Use different hotkeys.

ALT+F4 is the system keybind to close the current window.
#2
11/01/2008 (5:09 am)
Mostly in downloadble games in game portals like Big Fish, Oberon etc., when press Alt + F4 keys it shows a conformation window 'YES' or 'NO', then only quit when i press the 'YES' button. How is this possible?
#3
11/01/2008 (6:38 am)
Basically you override the window manager
1: You'll have to make the WM_CLOSE application event (in c++ code) not close the window by default
2: pop up a YES/NO GUI dialog much like how the ESC to quit dialog works
3: Then send the command to close the window.

Quote:You just have to identify the DIK codes for the keys, catch them in your own code and deal with them accordingly. Take a look at the DirectInput files in TGE as well as the DirectInput samples that come with the DirectX SDK to get a good understanding of what you need to do.

It's really not a good idea though if your application is a full screen app, as then you have no way to force a quit in order to recover if it fails.
#4
11/01/2008 (6:50 am)
From my understanding is that the Alt+F4 key combination can be intercepted. Windows will send an event message to the focused application upon the specified key combination and if the app doesn't return out of that event stating it handled that combination then the default windows condition occurs which is sending the close window event to the application as if the user clicked on the X button on the window tittle bar.

You know I thought alt f4 was actually binded some where in the torque scripts, but I just looked and nope not there. So, since when you actually do declare alt+f4 to become a key map bind and it still closes the Torque window that sounds like to me that the keyboard event handling has a bug in it. Or Torque does actually process the events and will execute your alt+f4 keybind, but it did not tell Windows that it would handle the event therefore it restored to the default condition of triggering a window close event of which Torque accepted and closed out.

Somebody needs to look into how Torque is dealing with keyboard events or in Windows platform case window messages.
#5
11/01/2008 (12:18 pm)
@mohanmartin - So to summarize, you would need to purchase a license to gain access to source code to achieve what you need.
#6
11/01/2008 (12:37 pm)
I was curious and got this working for myself. So yeah it can be done - but only in source and much as I outlined up above.