Game Development Community

Window focus callbacks

by Michael Cordner · in Torque Game Builder · 02/01/2006 (8:18 am) · 3 replies

Quick question, with all of the changes and the 1.4 integration, are there now callbacks for OS events such as window focus/loss of focus? The reason I'm asking is that I'd like to be able to pause the game and cut out the sound when the window focus is lost.

Thanks

#1
02/01/2006 (11:44 am)
Everyone needs to do this.. I haven't tested to see if they changed anything. If not you can try the solution I posted a while back. It can be found here:www.garagegames.com/mg/forums/result.thread.php?qt=33529
#2
02/02/2006 (1:04 am)
About all I can add is that below is one way that's been used albeit under Windows only. It would be very useful to have this cross-platform.

In "winWindow.cc" (WindowProc)...
case WM_ACTIVATE:
         windowActive = LOWORD(wParam) != WA_INACTIVE;
         if( Game->isRunning() ) 
            Con::executef( 2, "windowFocusChanged", windowActive ? "1" : "0" );

- Melv.
#3
02/02/2006 (12:56 pm)
Melv, You can maybe look at the SDL source code for ideas on a cross platform solution. They seem to have that down pretty good. I'm not saying cut n paste it, but to use as a reference ;D