Menuitems not clickable

I have created menuitems from the MainMenuBar.
I figured out out to make them clickable.
MenuItem.Enabled = True

how can i make the menuitem(s) execute some code when they are clicked.

You must add a menuhandler for your new menuitem.
Select the window (that should show the menuitem) in the IDE and use
Insert -> Menu Handler

Then select your MenuItem in the Inspector -> Menuitem Name PopupMenu and hit Enter
Then write your code.

David: you may find useful information using - in Google - this quest string:

site:developer.xojo.com MenuItem

It tooks me time, but I found the useful link:

http://developer.xojo.com/userguide/desktop-menus

There are also a selection of examples included with Xojo. They can be found here:

[quote=315319:@David Cullins]I have created menuitems from the MainMenuBar.
I figured out out to make them clickable.
MenuItem.Enabled = True

how can i make the menuitem(s) execute some code when they are clicked.[/quote]

It is unfortunate both menu titles and items within these menu titles are all called MenuItems. That makes your question somewhat imprecise. It would have been good that you post in macOS, Windows or Linux, because each platform has its own behavior.

When you say menuItems, you mean items within menus, right? Under macOS, only the items within a menu can be clicked.

Under Windows, menus titles themselves can be clicked.

Sorry I meant to say MAC OS as the environment.

I believe the answer the OP is looking for is “add a menuhandler” (see INSERT menu in Xojo IDE)

i know how to create a menu.
I am trying to make each menuitem execute some code.

To the Gentleman Axel.

when i right click on the MenuBar under “CONTENTS” all choices are grayed out.
the inspector gives no “popup option” for each of the menuitems.

I am using MAC os by the way. Sorry i did not mention this in the first post.

[quote=315781:@David Cullins]i know how to create a menu.
I am trying to make each menuitem execute some code.[/quote]
PLEASE READ THE DOCUMENTATION ON “MENU HANDLERS”… this is where the “code” goes to be executed when a menu item is selected.

A menu item will remain grayed out until code is attached via the MenuHandler for that menu item, regardless of its ENABLED setting

And Mac vs Win makes no difference here… the process is the same.

yep i got it.

thank you all…

This can be found in the Documentation folder of Xojo, Xojo Documentation.pdf, from the bottom of page 431 onwards, or here http://developer.xojo.com/userguide/desktop-menus about half way down :slight_smile:

Let us know if you get stuck.