.nib files tell Cocoa to initialize objects, such as
menus, windows, controller objects, etc. As you can
see, it handles both the GUI objects and the objects
that glue the GUI to your program.
Look into the Cocoa documentation at
developer.apple.com, or the information included in
/Developer/Documentation
Now, to making your program. I think the easiest way
would be to make a new project using the “SDL Cocoa
Application” template instead of the “SDL
Application” template. After that, copy your program
files (.h, .c, and so on) OTHER THAN SDLMain.h and
SDLMain.c from the old project to the new one. The new
SDLMain files will have some interesting features.
Modify the new SDLMain.m file as I suggested in
earlier posts, and build the program. You should be
able to use Cmd-Q and Cmd-H and so on. However, you
will see some new menu options (File|Open Game… and
so on). This is because the new project has added
methods and such to handle custom menu items. Once you
learn more about Cocoa programming, you can use them
as a starting point to making nice interface for the
OS X version of your software.
If you want, though, you can eliminate the menu items
by opening the file “SDLMain.nib”* in the new project,
clicking on the menu items in the sample menu that
will appear in the lower left of your screen, and
deleting them.
Good Luck!
John Tanner
*I realize I said “MainMenu.nib” before. The new
project is set up slightly differently.
— Alexander Bussman wrote:> Oh, yeah you’re right I can minimize it and it beeps
with
Cmd-anything-else 
Since I’m new to Mac programming (and xcode
ofcourse) I don’t exactly
know what a .nib file is 
Is it a file that holds data on how the window
should look (created
from the “GUI builder” (forgot the name of the
program))?
// Alexander Bussman
On 2004-10-15, at 16.25, John Tanner wrote:
Are you using a .nib file?
I just tried my approach without a .nib file, and
only
thing I could get the computer to recognize is
Cmd-M
for minimize. You see, the .nib-file less program
didn’t even have menu options for Quit and Hide!
You should be able to make your program’s window
minimize by pressing Cmd-M and make the computer
“beep” by pressing Cmd-anything else. If so, try
converting your project to a nib-based one. Later
today, I’ll reconstruct how I did that, if you
need
help.
John Tanner
— Alexander Bussman wrote:
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! 
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 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
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
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail