Adding Menu Functionality

The process for associating code with menu items in AcuBench is very straightforward. As you add items to your menu in the Menu Designer, AcuBench automatically associates an exception value with each item. You can either use this default value or use the Property window to enter a different exception value. To associate a menu item with code, select the menu item, then use the Event tab of the property window to create a Link To paragraph for that item.

When you build a menu, it is a good idea to associate keyboard shortcuts with each menu command. There are two ways to do this:

  1. Place the & character in front of a letter of the menu item in the Menu Designer. Users can invoke that menu item by pressing the Alt key and the designated letter.
  2. Use a runtime configuration file to assign a keyboard shortcut to each exception value associated with a menu item.

When you use a runtime configuration file to assign a keyboard shortcut, the steps are as follows:

  1. Add your item name in the menu designer, then enter the special character combination \t and the keyboard shortcut that you want to associate with the item. The result should look something like this:
    Add\tCtrl+A

    At runtime, the \t becomes a tab character, adding appropriate spacing between the menu item and its keyboard shortcut.

  2. Make a note of the exception value associated with your menu item. If you prefer, you can change the Exception Value property associated with the item in the Property window.
  3. To add a configuration file entry to tie the menu item to the keyboard shortcut that you have specified, open your configuration file. (In AcuBench, this generally means opening the Project Settings window, selecting the Runtime tab, and clicking Edit to open the Configuration File Editor.)
  4. Add an entry for the KEYSTROKE configuration file entry that specifies the exception value and the keyboard shortcut that you want to associate. The entry should look something like this:
    KEYSTROKE Exception=1003 ^A

    In the example, when the user presses Ctrl+A, an exception of 1003 is generated. Any code associated with that exception (key-status) value is then executed.

    More information about the KEYSTROKE configuration variable can be found in The KEYSTROKE Variable.

  5. Back in the menu designer, use the Event tab of the Property window to create a Link To paragraph associated with the menu item. This paragraph is invoked when a user selects the menu item or uses the keyboard shortcut associated with the menu item.