Disabling a menu item?

I would like to disable a menu item during a condition, but cannot find a way to do it. I checked the forum and even asked 2 different AI, which normally gives me very good info. However I cannot get it to work. Any pointers how to do this? I would like to disable the SaveFile menu item in the File menu.

theMenu.MenuAt(0).Enabled = False

You can use the Enabled Property of the DesktopoMenuItem:

<NameOfItem>.Enabled = False

https://documentation.xojo.com/api/user_interface/desktop/desktopmenuitem.html#desktopmenuitem-enabled

If the menu has AutoEnabled = True, then Xojo will manage the enabling / disabling its self. To gain manual control you should set AutoEnabled = false.

After that, as others have said, you can set Enabled to True or False as required. You can also use the MenuBarSelected event to set the state of menu items. Assuming we’re talking about the main menubar.

1 Like