General Interface is an open source project hosted by the Dojo Foundation

Assigning Hot Keys to Menus

To assign a hot key to a menu, you need to add or modify the CDF @jsxkeycode attribute in the CDF document associated with the control.

To assign a hot key to a menu command:

  1. Open the System > Menus and Toolbars folder in the Component Libraries palette.
  2. Drag and drop a Menu component onto your application.
  3. Edit the CDF document associated with the control and add the @jsxkeycode attribute to each menu command---New, Open, and Save. There are several ways to do this:
    • Edit the CDF document on disk and enter the XML URL in the Properties Editor palette.
    • Edit the CDF cache document and enter the XML Cache ID in the Properties Editor palette (The cache document isn't persisted).
    • Edit the XML String property in the Properties Editor palette.
      In this example, you'll edit the XML String property as follows:
  4. Select the Menu component in the Component Hierarchy palette or the Live Component view.
  5. Open the Properties Editor palette and click in the XML String value field.
  6. Add @jsxkeycode attributes to each menu command. Typically, the jsxexecute attribute would execute a function. In this example, an alert is used for the jsxexecute attribute for testing purposes to demonstrate that the hot key is working properly.

For example, your XML String value might look similar to this:

<data jsxid="jsxroot">
 <record jsxid="1" jsxtext="New" jsxkeycode="alt+shift+n"
  jsxexecute="alert('New menu is working');"/>
 <record jsxid="2" jsxtext="Open" jsxkeycode="shift+o"
  jsxexecute="alert('Open menu is working');"/>
 <record jsxid="3" jsxtext="Save" jsxkeycode="shift+s"
  jsxexecute="alert('Save menu is working');"/>
</data>
Test the hot key before assigning it, to be sure that it is not already used.

To test the hot key:

  1. Select the Menu component in the Component Hierarchy palette and click the Re-Fetch Data and Repaint button so that the CDF document in memory reflects the changes made to the XML String property.
  2. Click anywhere in the Live Component view to give focus to your application.
  3. Use the hot key for each menu command to test the functionality and to display the alert:
    1. Press alt+shift+n for the New command.
    2. Press shift+o for the Open command.
    3. Press shift+s for the Save command.

Contents

Searching General Interface Docs

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.