Secondary Menu Bar Inside Window?

Discussion in 'Mac Programming' started by Cactus Dan, Jan 16, 2012.

  1. macrumors newbie

    Joined:
    Aug 8, 2010
    #1
    Howdy,

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

    Like this:
    [​IMG]

    Adios,
    Cactus Dan
     
  2. macrumors 603

    Joined:
    Aug 9, 2009
    #2
    Use Java?
     
  3. thread starter macrumors newbie

    Joined:
    Aug 8, 2010
    #3
    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
     
  4. macrumors 603

    Joined:
    Aug 9, 2009
    #4
    If you have popup menus, you might be able to implement an internal menubar that way. Could be fugly, but maybe worth a shot.
     
  5. macrumors 68000

    Joined:
    Mar 29, 2009
    Location:
    USA
    #5
    Make a custom View that handles input, displaying labels, etc. Those don't look like a standard part of Cocoa.
     
  6. thread starter macrumors newbie

    Joined:
    Aug 8, 2010
    #6
    Howdy,
    Would that be an NSView?

    Adios,
    Cactus Dan
     
  7. macrumors 68000

    Joined:
    Mar 29, 2009
    Location:
    USA
    #7
    Yes. I made a simple one to imitate 'tabs' such as in Firefox.
     
  8. thread starter macrumors newbie

    Joined:
    Aug 8, 2010
    #8
    Howdy,

    Hey thanks for steering me in the right direction. I've actually got it working nicely:
    [​IMG]

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

    Adios,
    Cactus Dan
     
  9. macrumors newbie

    Joined:
    Apr 16, 2012
    #9
    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
     
  10. thread starter macrumors newbie

    Joined:
    Aug 8, 2010
    #10
    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
     

    Attached Files:

Share This Page