also add code here to reset buttons when alt+tabbing out, analogous to CGUI (thanks to Philip for mentioning the problem)

This was SVN commit r3004.
This commit is contained in:
janwas 2005-10-24 21:43:39 +00:00
parent 0d6dd7836d
commit 0a202da843
2 changed files with 26 additions and 1 deletions

View File

@ -23,6 +23,18 @@ InReaction GlobalsInputHandler(const SDL_Event* ev)
{
case SDL_ACTIVEEVENT:
g_active = (ev->active.gain != 0);
// tasked out
if(ev->active.gain == 0)
{
// reset all key/button state, so that we don't get any
// phantom events when returning to our app.
// see CGUI::ClearMouseState.
for(uint i = 0; i < ARRAY_SIZE(g_mouse_buttons); i++)
g_mouse_buttons[i] = 0;
for(uint i = 0; i < ARRAY_SIZE(g_keys); i++)
g_keys[i] = 0;
}
return IN_PASS;
case SDL_MOUSEMOTION:

View File

@ -319,10 +319,23 @@ void hotkeyRegisterGUIObject( const CStr& objName, const CStr& hotkeyName )
InReaction hotkeyInputHandler( const SDL_Event* ev )
{
int keycode;
int keycode = 0;
switch( ev->type )
{
case SDL_ACTIVEEVENT:
// tasked out
if(ev->active.gain == 0)
{
// reset all key/button state, so that we don't get any
// phantom events when returning to our app.
// see CGUI::ClearMouseState.
for(uint i = 0; i < ARRAY_SIZE(hotkeys); i++)
hotkeys[i] = 0;
}
// don't continue with the code below (this wasn't an input event)
return IN_PASS;
case SDL_KEYDOWN:
case SDL_KEYUP:
keycode = (int)ev->key.keysym.sym;