Windowed Mode lose focus...
by Pratik Murarka · in Technical Issues · 07/10/2008 (6:11 am) · 5 replies
Hi, all, Im running my game in windowed mode, the problem im facing is that i want to pause the game when the user clicks outside the game window(basically on game window losing focus). Is there any way by which we know in torque the window has lost focus, or is inactivated or minimized.
Also when we Alt+Tab, in the torque console "Activating DirectInput..." & "DirectInput deactivated." gets printed on the console.
--Pratik.
Also when we Alt+Tab, in the torque console "Activating DirectInput..." & "DirectInput deactivated." gets printed on the console.
--Pratik.
#2
07/10/2008 (9:40 pm)
Thanks a lot Rene...the function "onWindowFocusChange(%state)" does the work for me now !!! ;)
#3
07/10/2008 (10:47 pm)
Thanks a lot Rene...the function "onWindowFocusChange(%state)" does the work for me now !!! ;)
#4
I added this to my game.cs (in TGB) and now I only get the event if it is called and the state has changed (I was getting it more than once for the same state sometimes)
function onWindowFocusChange(%state) {
if ($LAST::onWindowFocusChange::state != %state) {
echo("onWindowFocusChange: " @ %state);
if (%state == 0) {
AutoPause();
} else {
UnPauseMainGame(true);
}
}
$LAST::onWindowFocusChange::state = %state;
}
08/15/2009 (4:29 pm)
Thanks for the info, Rene. I added this to my game.cs (in TGB) and now I only get the event if it is called and the state has changed (I was getting it more than once for the same state sometimes)
function onWindowFocusChange(%state) {
if ($LAST::onWindowFocusChange::state != %state) {
echo("onWindowFocusChange: " @ %state);
if (%state == 0) {
AutoPause();
} else {
UnPauseMainGame(true);
}
}
$LAST::onWindowFocusChange::state = %state;
}
#5
08/15/2009 (5:20 pm)
Interesting, I was actually looking for a way to pause the game when the user clicks outside the window.
Associate Rene Damm
In TGEA, you can define the methods GuiCanvas::onGainFocus and GuiCanvas::onLoseFocus to do the same thing.