Menus work differently on MacOS

I have been using the Windows version of RB/Xojo since RB 5.5. Today, for the first time, I loaded Xojo 2013r1.1 onto a MacMini M1 Ventura 13.4.1 and tried running my current desktop project. Most things operated as they did on Windows, but the menu is very different. Some menu items launch windows just as happens in the Windows version, but some menu items are grayed out if one item has been selected. If I close that window, the other menu items become available again. There is one item in the main menu bar that has no submenus under it. When I select it, nothing happens. I put a breakpoint in the menu handler and it never fires. These all work as expected when run under Windows. Is there some documentation that explains how menus work in MacOS? And how I can get the one that does do anything to work?

On the top menu bar on Mac, the menu item in the main menu bar alone doesn’t work.
It’s just a holder for (its) menu items.

Thanks for the help. Being a MacOS newbie, I didn’t know that. Perhaps you can also explain why the menu items are grayed out on the Mac and not on Windows. AutoEnable is set to true.

Have you provided handlers for the menu items in question?

TimStreaterTesters

Have you provided handlers for the menu items in question?

Yes. All the menu items work on Windows, but they are all grayed out when I run it on a Mac. The source code is stored in DropBox so both computers are accessing the same file.

Can you provide a sample project? and/or screenshots?

I’m a bit puzzled about your notion that menus seem to work “differently” on a Mac. My app runs on macOS, and on Win/Lin too. On the Mac, the menu bar is in its usual place - at the top of the screen. On Win/Lin, the menubar is attached to the top of the app’s main window.

Now: on all three platforms, the menus operate identically [1] - the only difference is where the menu bar is. So perhaps you could explain what you mean by “differently”.

[1] OK, some of the menu items (not many) move to other menus, but that is purely to make some items appear, for each platform, where the users of that platform would expect them to appear.

](https://forum.xojo.com/u/TimStreater)TimStreater
I’m a bit puzzled about your notion that menus seem to work “differently” on a Mac.

Detlef Kahner had the answer to my main problem. With the Mac, the items in the main menubar are just placeholders for subitems. Clicking on them does nothing. I am redoing my entire menu system and will follow up with screenshots if I still have a problem with menu items not being enabled.

Clicking on them causes that menu to be presented; you then select a menu item. Exactly the same behaviour as on a menubar (attached to a window) in WIndows and Linux.

Once I created an all new menubar with each menu item having submenus, all the menu items that have menuhandlers are enabled. At least they are enabled until one is selected, then everything in the menubar is disabled except Emoji and Symbols in the Edit menu. Closing the selected window enables all the other menu items. It acts like each window opens as a modal SheetWindow instead of a DocumentWindow. All the windows were created as DocumentWindows with Xojo 2023r1.1 running on Windows. But adding a new window and menuitem to show it while running on a Mac didn’t change anything. When I use the menu to open a window that has a button that shows a third window, the button works even though that third window cannot be opened from the menubar.

Just in case:

when you add a new window, add the main Menu Bar to it (none is set by default).

1 Like

Sounds like whatever you are doing has opened a new window, which does not have a ‘menubar’ property set, and so does not have a menu event handler.

Where you put these handlers will depend upon scope:
For example ‘Copy/Paste/Delete/Amend’ style actions belong as menu event handlers in the code of individual windows, usually.
‘Open / New/ Import/Help’ don’t normally relate to individual windows, and so would expect to see handlers in the Application object.

If you have a ‘clear dialog’ menu item, it would make no sense to have that enabled when showing an ‘About’ dialog, or a read-only screen. Having no handler for it on those dialogs means the menus would be disabled.

All this assumes that you have AutoEnabled selected for the menu items of course, or that you have code in the MenuBarPressed event to manually enable/disable individual items.

Alternate way, add Toolbar to the project, create its toolbar items, then drag the Toolbar into the window.

Toolbar.Action code:

Select Case Item.Name
case "Tb_Gameinfo"
end select

Depending on the situation, if a Toolbar item is currently available, add a method to the window, enabling or disabling each individual toolbar item:

Toolbar1.TbItemName1.Enabled=true
Toolbar1.TbItemName2.enabled=true
Toolbar1.TbItemName1.Enabled=false
Toolbar1.TbItemName2.enabled= false

several times the bugs of Windows menus were communicated to Xojo, but we are waiting for years that finally they decide to resolve them
 and still waiting
 the misbehaviour belongs to autoenable, enabled and visible properties.