KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Determine programmatically if menu item is disabled
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: January 4, 2021

When creating a menu with various items, occasionally you want to disable one or more of those items. What if you wanted to add some code that only applies to menu items that are enabled? How could you determine programmatically if the menu item is disabled?

You could accomplish this by using the command SET MENU ITEM PROPERTY. This command allows you to set a custom property on a menu item. Thus, you can set a custom "disabled" property on a disabled menu item, like this:

SET MENU ITEM PROPERTY($menu;1;"disabled";True)

Then, when you need to determine if it is disabled, use GET MENU ITEM PROPERTY on the "disabled" property for the menu item, like this:

GET MENU ITEM PROPERTY($menu;1;"disabled";$menuItem1Disabled)

The variable $menuItem1Disabled would then return the boolean value True.