[SDL] Cocoa & SDL
Thomas Harte
thomas.harte at gmail.com
Sun Nov 19 04:39:59 PST 2006
I want my SDL application to have a full Cocoa UI. I've read various old threads
on Cocoa & SDL and so far am using setenv to set a non-zero value for
SDL_ENABLEAPPEVENTS and have added a sendEvent handler to my implementation of
SDLApplication that checks if incoming events are keyboard related, and if so
throws them away if command is not pressed. With a bit of nib magic from
Interface Builder that gives me a fully interactive Cocoa UI with the one
obvious defect — it isn't responding to keypresses that don't have command
pressed. As a result things like "File->Save" are almost impossible to use. Of
course if I don't filter keyboard input like this then every time the user
presses a key I get an error beep as Cocoa thinks the user has pressed a key
that doesn't do anything.
My slightly hacky solution so far is to keep an internal flag of any time I
launch a dialogue that would want proper keyboard input and not to filter it
out until that dialogue has finished. I'm wondering if there is a better
solution that can be implemented while still separating my Cocoa code from the
main body of my ordinary cross-platform code. Perhaps some sort of invisible
window that accepts ordinary keypresses while my app is active but does
nothing with them?
I'd be curious to hear what others have done to get around this problem.
P.s. this is the only forum I've ever posted to that has made me hand-edit my
post so that it has no lines longer than 80 characters. Can that really not
be done automatically?
More information about the SDL
mailing list