Works on windows but not Mac. How do I get code to execute on the Mac when one of the top most menu bar items are selected. It works fine for submenus but ignores my code when there is no submenu. Thanks in advance for your help.
Hi @Rebecca Walker
Let’s say you did add a new Menu called
MyMenu to the
Then, you add a new first level menu called
After that, you can add a new
Menu Handler (for example to a Window) typing
myMenuMyMenuItem as the handler name in the Inspector Panel.
Put the code you want to execute as response in the associated Code Editor, return True… and done!
That should work!
Perhaps I am not understanding but I want to click on MyMenu and have it execute code. I can do this in Windows.
Please show your code. This should work on the Mac the same way as on Windows.
Just create the main menu item then link it to a menu handler as shown above.
Maybe you can rework you menu hierarchy so the menu items are grouped by “kind of task” under your main menus? That way it would be compatible with all the Desktop targets, you would be able to add MenuHandler for such menu items, and offer a better UI design to your users from the menu point of view IMHO.
I know I can rework the menu but I was hoping you had a solution that would allow the main menu to work the same between windows and mac.
This cannot be done on macOS as far as I know. It’s part of the macOS system design that selecting a menu with subitems does not fire an action.
@Tim Parnell: since when?
I selected “Neu analysieren”:
And now I must check if I have a bug somewhere:
That is news to me!
I’m almost positive that’s what OP is trying to accomplish on a MenuBar level menu.
I’m not really sure what the OP wants to do.
I think the question is not about a menu item added to a main menu item (the topmost one, sitting in the MenuBar).
The topmost menu items from the menubar can’t fire actions under macOS.
Okay, thank you.