[SDL] Apple/Command button

Alexander Bussman buxman at telia.com
Fri Oct 15 03:04:15 PDT 2004


I tried this approach now but it seams like it's not working.
Cmd-Q and Cmd-H doesn't work.
Maybe I misunderstood you, but this is going to make Cmd-Q and Cmd-H to 
work without any calls from my event loop?

// Alexander Bussman

On 2004-10-14, at 19.33, John Tanner wrote:

> I have been working on another approach to this
> problem. My approach is for programs made using
> Project Builder/XCode.
>
> I add code to the SDLMain.m file of the project.
>
> To get Cocoa to hear keystrokes (such as Cmd-Q, Cmd H
> and the like), I add the statement 	
>  setenv ("SDL_ENABLEAPPEVENTS", "1", 1);
> to the applicationDidFinishLoading: method in the
> class SDLMain.
>
> Next, I make sure Cocoa ignores keystrokes that do not
> involve the command key, as Cocoa won't be able to
> handle those; it'll "beep" at you. If your users don't
> mind a "beep"ing computer while they play games, well,
> you don't need to do this next step! :-P
>
> In the implementation of SDLApplication, I add the
> following method, which overrides the sendEvent:
> method in NSApplication:
>
> - (void)sendEvent:(NSEvent *)anEvent {
> 	if( NSKeyDown == [anEvent type] || NSKeyUp ==
> [anEvent type] ) {
> 		if( [anEvent modifierFlags] & NSCommandKeyMask )
> 			[super sendEvent: anEvent];
> 	} else
> 		[super sendEvent: anEvent];
> }
>
>
> This seems to work, but I have only tried it in one
> application.
>
> Thanks to the creators of the SDL Custom Cocoa
> Application template. I would have never thought of
> setting SDL_ENABLEAPPEVENTS without it.
>
> John Tanner
>
> --- Alexander Bussman <buxman at telia.com> wrote:
>
>> Hi!
>>
>> I have a hopefully easy question.
>> I wonder if there is a simple way to implement for
>> example Command-Q
>> (quit) and Command-H (hide) in a SDL application on
>> OS X.
>>
>> I haven't found any information about how to do
>> this.
>>
>> Thanks for your help
>> // Alexander Bussman
>>
>>
>> _______________________________________________
>> SDL mailing list
>> SDL at libsdl.org
>> http://www.libsdl.org/mailman/listinfo/sdl
>>
>
>
>
> 		
> _______________________________
> Do you Yahoo!?
> Declare Yourself - Register online to vote today!
> http://vote.yahoo.com
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>





More information about the SDL mailing list