Sort ApplicationMenuItem?

Hi!

Given are two ApplicationMenuItem items. One labeled “About $App” and another “Check for Updates”.

Xojo sorts them in the wrong way. “Check for updates” is first, the “About” is the second.

How to order them? On a Mac “About” has to be the first item in this list. I can’t modify the Application menu in Xojo – any hints?

I don’t believe you can “sort” them…

Do they not follow the order that they appear in the Design Time Menu Editor?

Is seems to be but that’s far beyond practical

why not practical… drag them to the order you desire… you should not have more that 3 or 4 custom items on that menu to begin with

One Example…

On Windows, the “About” is located in a “?”-Menu which is always the last one
On Windows the Update-Check is often located in the File-Menu

And then you have a menu order like File – Edit – ?

And the result is “Check for Updates” comes first, “About” second. And that’s very inflexible and not useful when developing for different platforms

I see two possibilities:

  • Duplicate the menubar (for OS X) and move all AppleMenuItems to the Help menu item - in the order you want them to appear on the application menu on OS X. In the App.Open event replace the menubar in a #if TargetCocoa clause. Of course you would have to update the duplicate if the menubar is updated in the IDE.
  • Create and add the items dynamically in the order you want them in the application menu on OS X and insert them at the correct place in the menubar programmatically.

If you are talking meeting the guidelines for both OSX and Windows… there is a 3rd way

Create two menu ENTRIES (not two menubars)… and if compiling for WIndows, make one invisible, and for OSX make the other invisible…

That is how I build my menus… ONE menubar … platform specific menu entries

[quote=106204:@Pascal B. Kreil]One Example…

On Windows, the “About” is located in a “?”-Menu which is always the last one
On Windows the Update-Check is often located in the File-Menu

And then you have a menu order like File – Edit – ?

And the result is “Check for Updates” comes first, “About” second. And that’s very inflexible and not useful when developing for different platforms[/quote]

You can have several menu bars and select them in each window with

Self.MenuBar = New MainMenuBar

So you can design the menu bar for Windows, the one for Linux and the one for Mac, then switch automatically in your app with

#If TargetWin32 then Self.MenuBar = WinMenuBar #Elsif TargetMacOSX then Self.MenuBar = MacMenuBar #Elseif TargetLinux then Self.MenuBar = LinuxMenuBar #Endif

[quote=106213:@Michel Bujardet]You can have several menu bars and select them in each window with

Self.MenuBar = New MainMenuBar

So you can design the menu bar for Windows, the one for Linux and the one for Mac, then switch automatically in your app with

#If TargetWin32 then Self.MenuBar = WinMenuBar #Elsif TargetMacOSX then Self.MenuBar = MacMenuBar #Elseif TargetLinux then Self.MenuBar = LinuxMenuBar #Endif [/quote]

This has its own set of problems

OK… Several dirty tricks :slight_smile:

Thanks – I’ll play around and check which one suits best. I was hoping that Xojo can handle it on it’s own.

Hey Xojo-Guys! There’s room for improvement! :wink:

The missing . may mean that further details are on the way.

You end up having to do ALL of the menu bar enabling dynamically
You cannot use the name of the menu items as though it is / was a globally available item

Just try :

  1. create a new desktop project
  2. remove the menu bar assignment from app & window1 (set them both to none)
  3. add a new menu bar (menubar1) with some new top level and menu items (mine are cleverly UntiledMenu then UntitledItem)
  4. in window1.open put
    me.menubar - menubar1 // it won’t matter which here
  5. in window1.enablemenuitems try
    untitledItem.enabled = true

you will get a this item does not exist error

[quote=106249:@Norman Palardy]2) remove the menu bar assignment from app & window1 (set them both to none)
[/quote]

Why remove the default bar ?

And, while your demonstration indeed generates an error, my suggestion was not to have different menu items in the menu bars, but the very same ones, only placed in different menus. Just to make sure for instance About goes into Help on Windows and into the Apple Menu on Mac.

Keep it simple is key :slight_smile:

Created a feature request. Case 34265.

[quote=106290:@Michel Bujardet]Why remove the default bar ?

And, while your demonstration indeed generates an error, my suggestion was not to have different menu items in the menu bars, but the very same ones, only placed in different menus. Just to make sure for instance About goes into Help on Windows and into the Apple Menu on Mac.

Keep it simple is key :)[/quote]
You’ll still have issues
Really

:frowning: