View Full Version : How do I use a NIB file for my main menu in SDL?
ferum
2006.08.10, 11:16 AM
according to this tutorial (http://www.meandmark.com/sdlopenglpart2.html) I can use a NIB file for my application's menu bar. I think that I would like to do this because using the template's SDLMain.m with the SDL_USE_NIB_FILE defined as zero gives me a menu bar with nothing but the minimize item functional. Problem is, I have no idea how to use a NIB file. Could someone tell me what I need to know to do this or point me in the direction of a tutorial that tells me how to do it?
Thanks!
szymczyk
2006.08.10, 04:13 PM
There is a nib file called SDLMain.nib, located in the Resources folder of the SDL framework. Make a copy of it, move it to your project folder, and rename it SDLMain.nib. Add your copy to your project, and you have a basic menu bar.
Open the nib file in Interface Builder and add any menu items you want to add. It's not too hard. Double click the MainMenu item in the nib file menu to open the menu bar. Click the Cocoa Menus button in the Palettes toolbar. To add a menu to the menu bar, drag one of the menus (Application, File, Edit, Window, etc.) to where you want it to be in the menu bar. To add an item to a menu, drag the Item entry in the Cocoa Menus palette to the menu. Double-click an item or menu to change its name.
ferum
2006.08.11, 09:30 AM
Ok, Nib or no Nib, how do I get a fully functioning menu bar with "Quit" "Minimize" "Hide" and "Hide all Other"?
Without a nib file I have an empty *app name* menu and a Window menu with a functional "minimize " option. With a nib I have a fully filled in menu with none of the options working, and my window replaced with a blank window.
szymczyk
2006.08.11, 02:44 PM
I don't know what's going wrong with the nib file. I created a SDL OpenGL application from the template that comes with the SDL download for Mac OS X. I added a copy of the SDLMain.nib file to the project and made the change to SDLMain.m to use the nib file. Everything worked except the Quit menu item was disabled. I added SDLMain.nib to the project that accompanied my tutorial, and I got the same behavior: everything worked except the Quit item was disabled.
What I would suggest is looking at one of the two examples I mentioned and see what you're doing differently. Using nib files with SDL should work without you having to do much.
ferum
2006.08.11, 05:25 PM
Ah, changing the nib file's name to "MainMenu.nib" made it work. Now how do I fix the Quit item?
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.