I’m rather new to Interface Builder in OS X. If I create a new project using the Cocoa Application template, it auto-creates a MainMenu.nib file for me. If I drag that file into my existing SDL 1.3 application, it doesn’t get used – instead, a more basic menu bar seems to get created automatically by SDL. I’m wondering how I can use my own menu bar instead of having SDL create a basic one for me?
-Vern
You have two options:
-
Use the built-in menu from SDL, and use Cocoa calls (NSMenu) to add
menus to the menu bar that SDL created.
-
Before calling SDL_Init(), call [NSApplication sharedApplication] and
create your main menu (either programmatically or with a .nib file). SDL
won’t set up a menu for you if it sees one already exists.
–ryan.On 06/07/2011 11:42 AM, VernJensen wrote:
I’m rather new to Interface Builder in OS X. If I create a new project
using the Cocoa Application template, it auto-creates a MainMenu.nib
file for me. If I drag that file into my existing SDL 1.3 application,
it doesn’t get used – instead, a more basic menu bar seems to get
created automatically by SDL. I’m wondering how I can use my own menu
bar instead of having SDL create a basic one for me?
Ryan C. Gordon wrote:
You have two options:
-
Use the built-in menu from SDL, and use Cocoa calls (NSMenu) to add
menus to the menu bar that SDL created.
-
Before calling SDL_Init(), call [NSApplication sharedApplication] and
create your main menu (either programmatically or with a .nib file). SDL
won’t set up a menu for you if it sees one already exists.
Thanks Ryan. I tried calling [NSApplication sharedApplication] (have no idea what this does), and indeed, now SDL does not create a menu for me. But neither does it use the menu in my .nib file. Is there code I must specifically call to tell Cocoa to use the .nib file? Sorry, I’m so new to all of this!
If you have a webpage that’d point me in the right direction, I’d be happy to read that too. Thanks again.
If you have a webpage that’d point me in the right direction, I’d be
happy to read that too. Thanks again.
http://cocoadev.com/ is a good start if you want to really get into
Objective-C and Cocoa.
The likely problem (having very little experience with this myself) is
that you didn’t specify your .nib file in your app’s Info.plist…if
you’re building your app like a Windows .exe (or a Unix binary)–no .app
bundle directory thing–you’ll need to load the nib yourself (use the
NSNib class).
–ryan.