That’s an idea that has occurred to me as well at one point, in the
context of handling menu keyboard equivalents on Mac OS. My application
is cross-platform for the most part, but has a Mac-specific part that
sets up and handles a Cocoa menu bar. Some menu items in there have
keyboard equivalents, but they don’t work unless I check for them
manually in my SDL event handling. It would be nice to have an
SDL_PassEvent() function or something that could be called when the
application wants to pass an event that it doesn’t want to handle itself
back to the OS, where, on Mac OS, a key event would eventually be
matched against the menu keyboard equivalents. (I totally agree with
everyone that the application needs to get a chance to process a key
event itself first, before it is eaten up by the keyboard equivalent
handling of the OS (or windowing toolkit or window manager or
whatever).)I have no idea how easy this would be to implement on different
platforms, though.That’s a very interesting idea. I think it would need to be implemented
in one of
two ways. Under Windows, events are sent to the application from the OS
as
“messages,” which SDL intercepts and processes to create SDL events. I
assume a similar system is at work in other OSes. So if you want to
pass a
SDL event back to the OS, you either need to extend the SDL event
structure
with a pointer back to the original message (which means keeping the
message
in memory somewhere until the SDL event that it’s connected to has been
taken
care of) or implementing a system that will run the process in reverse,
creating an
OS message from an SDL event.Neither of these are particularly efficient. If the only issue is
menus, I think a better
solution would be to extend the event system as follows:1.) Optionally, upon initialization, check to see if the current window
has menus. (This
could be skipped under Windows, as every window has a System menu with
one
registered keyboard shortcut by default. This may or may not be true
under other
OSes.) Also, if it’s possible to not have a menu, set up an
SDL_EnableMenu() routine
that the app calls when it creates menus.2.) If menus are currently enabled, when trapping keystrokes, the event
system should
automatically run each keypress by the window manager’s menu system to
see if it’s
a valid shortcut, in addition to generating an SDL event. (This is
probably the simplest
way to do it. It would be the application programmer’s job to make sure
that the control
set doesn’t overlap with the registered menu shortcuts, to keep the same
keypress from
having two effects.)Good idea? Bad idea? What do you think?
I’d like to see this extended a little further to include keys that are
not only menu keys for example ALT+TAB, If I was to develop and I really
am, an enviroment that takes over the entire screen sorta like an OS
inside an OS that creates its own windows etc inside of this SDL
enviroment I still want the interface to be consistant with the OS user
interface… I want to allow ALT+TAB to switch the windows in my SDL app
etc…
perhaps SDL_disableOSKeys(true|false) ?
Graham.On Mon, 05 May 2008 16:57:58 +0100, Mason Wheeler wrote:
----- Original Message ----
From: Christian Walther
To: sdl at libsdl.org
Sent: Sunday, May 4, 2008 6:19:38 AM
Subject: Re: [SDL] Alt-F4 not working on Windows
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
–
Using Opera’s revolutionary e-mail client: Opera Web Browser | Faster, Safer, Smarter | Opera