PDA

View Full Version : Secondary Menu Bar Inside Window?




Cactus Dan
Jan 16, 2012, 03:43 PM
Howdy,

How do you create a secondary menu bar inside a window?

Like this:
http://www.cactus3d.com/WindowMenu.jpg

Adios,
Cactus Dan



chown33
Jan 16, 2012, 04:18 PM
Use Java?

Cactus Dan
Jan 16, 2012, 04:29 PM
Howdy,

Ooops. Sorry about that. I reckon I forgot to mention what programming language. :o

I'm using C++/C/Objective C, building upon the glfw library code.

Adios,
Cactus Dan

chown33
Jan 16, 2012, 04:57 PM
If you have popup menus, you might be able to implement an internal menubar that way. Could be fugly, but maybe worth a shot.

robvas
Jan 16, 2012, 05:17 PM
Make a custom View that handles input, displaying labels, etc. Those don't look like a standard part of Cocoa.

Cactus Dan
Jan 16, 2012, 06:04 PM
Howdy,
Make a custom View that handles input, displaying labels, etc. Those don't look like a standard part of Cocoa.
Would that be an NSView?

Adios,
Cactus Dan

robvas
Jan 17, 2012, 07:16 AM
Howdy,

Would that be an NSView?

Adios,
Cactus Dan

Yes. I made a simple one to imitate 'tabs' such as in Firefox.

Cactus Dan
Apr 1, 2012, 03:16 PM
Howdy,

Hey thanks for steering me in the right direction. I've actually got it working nicely:
http://www.cactus3d.com/InViewMenu.jpg

It works pretty much just like the main menu bar. ;)

Adios,
Cactus Dan

rgbworld
Apr 16, 2012, 09:14 PM
Hi Dan,
Any chance you could share your solution? I am rather new at cocoa development, so I could really use a comprehensive description on how you accomplished your secondary menu bar.

Possibly a code example and nib?

Thanks in advance!
Chris

Cactus Dan
Apr 16, 2012, 10:55 PM
Howdy,

Well, actually, I did that using C++/Objective-C++ without any nib, for the CPPAppKit project I've been doing as an experiment. It is really quite complicated, as I created my own c++ menu classes. Initially I tried using the NSMenuItem and NSMenu classes for the drop down menus, which did work, but I didn't like the results. I wanted them to have squared corners, and also wanted the possibility of adding background color.

But basically, the menu bar and menu item are wrapped to an NSView and the drop down menu is wrapped to an NSPanel. The menu item has subviews of NSTextView. If its a menu bar item then it only has one text subview for its title, and if its a sub menu item then it has 3 text subviews, one for the check mark, one for the title and one for the hot key list. The classes do their own event handling.

The whole project is mostly C++, with minimal Objective-C++ wrappers to communicate with the AppKit framework. I don't know if the code would be of much help if you're strictly working in Cocoa Objective-C but you're certainly welcome to it.

Adios,
Cactus Dan