[SDL] Alt-F4 not working on Windows

Christian Walther cwalther at gmx.ch
Sun May 4 06:19:38 PDT 2008


Pierre Phaneuf wrote:
> Traditionally, in GUI toolkit, what happens is that either the
> application provides a callback to the toolkit that gets called for
> each messages and returns whether the application handled the message
> or not, or there is a "get message" function, and an application is
> supposed to call some "dispatch message" if it's not a message that it
> found "interesting" (i.e. it didn't handle it). SDL does *not* provide
> this mechanism: either the application handles the message, or it's
> dropped on the floor without further processing.
> 
> If I remember correctly, what happens on Windows is that the
> application gets the Alt-F4 key pressed (well, okay, released,
> actually, if I'm not mistaken, but you get the idea) message, and if
> you want to do something with it, you do so, and don't call
> DispatchMessage. If your application didn't handle it and calls
> DispatchMessage, it will post itself a WM_DESTROY (or WM_CLOSE? I
> don't remember) message, which the application will then shortly
> receive.

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.

I have no particular opinion on the immediate Alt-F4 issue at hand. Just 
wanted to express my interest in an idea that may be worth looking into 
for SDL 3 or something. :)

  -Christian



More information about the SDL mailing list