PDA

View Full Version : Can't get SDL_APPINPUTFOCUS to work



Christian Knudsen
12-06-2011, 12:35 PM
I'm using FreePascal with SDL and am trying to keep track of whether or not my program has mouse and input focus and whether or not it's minimized. Keeping track of mouse focus seems to work fine, but it only registers a loss of input focus. I can't get it to register when it gains input focus again. Anything wrong with my code?



WHILE SDL_PollEvent(@Event) <> 0 DO BEGIN
CASE Event.Type_ OF

SDL_ActiveEvent :
CASE Event.Active.State OF

SDL_AppInputFocus :
IF Event.Active.Gain = 0
THEN ProgramHasInputFocus := F
ELSE ProgramHasInputFocus := T;

SDL_AppMouseFocus :
IF Event.Active.Gain = 0
THEN ProgramHasMouseFocus := F
ELSE ProgramHasMouseFocus := T;

SDL_AppActive :
IF Event.Active.Gain = 0
THEN ProgramIsActive := F
ELSE ProgramIsActive := T;

END;

...

END;
END;

Christian Knudsen
12-06-2011, 03:19 PM
Never mind. I figured it out. It's bitwise, of course.