Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cactus Dan

macrumors member
Original poster
Aug 8, 2010
30
0
Howdy,

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

Like this:
WindowMenu.jpg


Adios,
Cactus Dan
 

Cactus Dan

macrumors member
Original poster
Aug 8, 2010
30
0
Howdy,

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

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

Adios,
Cactus Dan
 

chown33

Moderator
Staff member
Aug 9, 2009
10,740
8,416
A sea of green
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

macrumors 68040
Mar 29, 2009
3,240
629
USA
Make a custom View that handles input, displaying labels, etc. Those don't look like a standard part of Cocoa.
 

Cactus Dan

macrumors member
Original poster
Aug 8, 2010
30
0
Howdy,

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


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

Adios,
Cactus Dan
 

rgbworld

macrumors newbie
Apr 16, 2012
3
0
Share secondary menu bar source code?

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

macrumors member
Original poster
Aug 8, 2010
30
0
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
 

Attachments

  • CPPAppKitTest.zip
    79.1 KB · Views: 177
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.