The "Main" menu in OS X - How to use it?
BlitzMax Forums/MaxGUI Module/The "Main" menu in OS X - How to use it?
| ||
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 |
| ||
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. |
| ||
Thanks Brucey. I'll take a look at those. It's a shame BlitMax doesn't support it out-of-the-box. |
| ||
Has QtMax died? The google code pages are empty, and there's no download there!? |
| ||
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. |
| ||
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. |
| ||
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? |
| ||
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. |
| ||
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! |
| ||
Ah. I see. If I change the name of my source file, the main menu will be named accordingly! It's a start :) |
| ||
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. |
| ||
Thanks d-bug - That looks great! Taking a look now... |
| ||
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? |
| ||
Oh, I see what's happening. I'm creating the window with a Graphics call instead of creating it using MaxGUI. |