[SDL] Alt-F4 not working on Windows

Abhinav Lele abhinav.lele at gmail.com
Wed Apr 30 15:07:10 PDT 2008


You need to check your code. Alt + F4 works on windows. You have to
check for the event of Alt + F4 and then quit.

        SDL_Event event;
	int flag;
	flag = SDL_PollEvent(&event);
	if(flag) { // flag == 1 implies event to be checked for
		switch(event.type) {
			case SDL_QUIT:
				return false; // no need for break;
			case SDL_KEYUP:
			case SDL_KEYDOWN:
				cout << "Key !\n";
				if(event.key.keysym.sym == SDLK_F4 && (event.key.keysym.mod ==
KMOD_LALT || event.key.keysym.mod == KMOD_RALT)  ) return false;
				//return true;
				break;
			default:
				break;
		}

This is a code snippet of how I catch alt + f4 in one of my apps. the
snippet returns whether to keep running or not.

On Wed, Apr 30, 2008 at 11:53 PM, Christoph Kobe <christoph at kobenetz.de> wrote:
> Hi,
>  I've been using the SDL for one week now and I'm quite happy with it.
>
>  But there's one thing I noticed: When I press Alt-F4 to close the App it won't.
>  I'm catching the SDL_QUIT event, but it only occurs when I press the X to close the window, Alt-F4 won't do the job.
>
>  In the release notes it says that from version 1.2.10 this problem is fixed, I use the SDL-devel-1.2.13-VC6.zip package.
>
>  Any Ideas?
>
>  _______________________________________________
>  SDL mailing list
>  SDL at lists.libsdl.org
>  http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>


More information about the SDL mailing list