KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Centralizing the methods of all menu items
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: April 25, 2003
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

The following example method is an example of how to centralize of menu item method call to one single method.


` Project Method: Menu_Manager

C_TEXT($SelectedMenuItem)
$SelectedMenuItem:=Get menu item(Menu selected\65536;Menu selected%65536)

Case of
: ($SelectedMenuItem="New Record")
` Call a method to create a record
: ($SelectedMenuItem="Next Record")
` Call a method to load the next record
: ($SelectedMenuItem="Previous Record")
` Call a method to load the previous record
: ($SelectedMenuItem="Print Daily Report")
` Call a method to print a daily report
: ($SelectedMenuItem="Print Quarterly Report")
` Call a method to print a quarterly report
End case

Instead of hardcoding a specific method to a method item, associate the Menu_Manager project method to all menu items. Make sure that you modify the condition in each Case-of statement to match the title of your menu items.

Note: By using this approach, you will be able to determine which method you want executed for a specific item dynamically.