The "Main" menu in OS X - How to use it?

BlitzMax Forums/MaxGUI Module/The "Main" menu in OS X - How to use it?

Murilo(Posted 2010) [#1]
When I run my OS X BlitzMax app, the app itself has a "Main" menu. How do I reference/use this menu in my app?

I want the menu to reflect the name of the app itself (as with every other Mac app), and I also want to add a "Preferences" menu item to it. AppTitle doesn't appear to have any effect on it.

Is this actually possible in BlitzMax?

Ta


Brucey(Posted 2010) [#2]
Not with the "default" app menu, which is a custom creation of BlitzMax.

But there are ways around it. For example wxMax and QtMax both have the ability to create ones own, and work with it. They both do it in slightly different ways.

So, it's certainly possible.


Murilo(Posted 2010) [#3]
Thanks Brucey. I'll take a look at those.

It's a shame BlitMax doesn't support it out-of-the-box.


Murilo(Posted 2010) [#4]
Has QtMax died? The google code pages are empty, and there's no download there!?


Brucey(Posted 2010) [#5]
No. It's still work-in-progress. I just mentioned it as a point that it's possible to work around the problems with the built in stuff.


Of course it all depends on what you want to do... if you are working on mostly graphics based stuff, or a more complex GUI app.


Murilo(Posted 2010) [#6]
Ah. I see. Thanks

I think BlitzMax's "Main" menu looks a bit naff (an inconsistent with the norm), so I might end up going back to C# and Mono. I don't really want to have to change from cocoa just becauseMax doesn't let me work with the app's main menu. What a shame. I was starting to enjoy working with Max again.

Thanks for your help though.


Murilo(Posted 2010) [#7]
Just giving the menu the same title as the app would've been good enough. Ideally, I'd have liked to add my "About" and "Preferences" menu items to the main app menu. I wonder why BLR just set it to "Main" and left it at that?


Brucey(Posted 2010) [#8]
The Cocoa code for the menu is in brl.mod/appstub.mod/appstub.macos.m, if you are interested.

It's actually quite possible to implement your own appstub module if you don't want to change the original.
I had a new option added to bmk (the build system), -b, which lets you specify the one you want.

Possibly with a bit of work, it should be doable to add some extra functionality.


Murilo(Posted 2010) [#9]
Ah. Thanks again. I'll take a look (not that I know what I'm looking for ;)).

I've can see the method and call...

createAppMenu( [NSString stringWithCString:p] );

...but I have no idea what stringWithCString is or what value is being passed in. Google, here I come!


Murilo(Posted 2010) [#10]
Ah. I see. If I change the name of my source file, the main menu will be named accordingly!

It's a start :)


d-bug(Posted 2010) [#11]
If you like, you can also use CocoaExt. It has support for adding menu items to the application menu and some other extended gadget features. Its still beta, but the menu part is working well at the moment.

The following code adds the Preferences Item to the application menu:
Local MyPreferencesMenu:TGadget = CocoaCreateMenu("Preferences...", CocoaApplicationMenu(), KEY_COMMA, MODIFIER_COMMAND)


Keep in mind, that this module doesn't support menu tags or the original MaxGUI localization for the extended gadgets. It uses the original localization functionality of OSX, where you have to add a language.lproj folder into your bundles resources folder and add a localized.strings file to it.


Murilo(Posted 2010) [#12]
Thanks d-bug - That looks great!

Taking a look now...


jhans0n(Posted 2010) [#13]
Sorry to resurrect this thread, but I tried the CocoaExt technique mentioned here, and while it added a Preferences menu item to the Application Menu, it is grayed out and I can't figure out how to enable it. What do I have to do to make it not grayed out?


jhans0n(Posted 2010) [#14]
Oh, I see what's happening. I'm creating the window with a Graphics call instead of creating it using MaxGUI.