KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to programatically delete a menu
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: May 22, 2007

The 4D language contains a command to delete a menu item (DELETE MENU ITEM) but not to delete a menu.

You cannot, technically, delete a menu in 4D. Instead you can use multiple menu bars to simulate a menu being deleted.

Simply create two menu bars, one with the desired menu and one without, and swap the menu bars as needed with the MENU BAR command. Of course all of the other menu items should match so that the interface remains consistent between to two menu bars. Try wiring the un-affected menus together so that you do not need to duplicate all of the menus and menu items.

With this technique it is quite simple to "delete" a menu.

It is also worth noting that the guidelines for user interfaces from both Microsoft and Apple recommend avoiding this. It is considered better to disable the menu items but not delete the entire menu so that the user is still aware of the complete functionality and does not become confused.

Related resources:

Microsoft User Interface guidelines:
https://msdn2.microsoft.com/en-us/library/aa906106.aspx

Apple Human Interface Guidelines:
https://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html