Menus and Key BindingsMenus are used to place functions that are executed often in a convenient place where they can be accessed quickly. The menuing system in e93 is dynamic. Menus can be added or deleted at any time. There are two Tcl commands used to add/delete menus: addmenu - adds or replaces a menu in the menu bar. deletemenu - deletes a menu, and its children from the menu bar. Example:
This command adds a menu at the end (LASTCHILD) of the root menu {}. The new menu is called Test, it has a keyboard equivalent of Command-Shift-A, and when selected, it will bring up a dialog box with a test message in it. To delete the menu:
Keys can also be bound to functions within e93. Key binding is much the same as defining menus. The major difference is that key bindings have no visual representation (as in a menu item that the user can see.) Also, key bindings may be more versatile than menu key equivalents, allowing a richer set of key combinations to be bound to functions. For example, menu key equivalents only function when the command key or command+shift is pressed, but bound keys can be bound to virtually all combinations. There are two major key binding functions: bindkey- bind a key combination to a Tcl script. unbindkey - remove a bound key combination. Using the menu example from above, if we wanted to bind the function key F5 to bring up the test dialog box, the command would be:
To get rid of the binding:
All those 0s are called the "modifier string" they tell which modifier keys should be in which states for the binding to take effect. In this example, no modifiers can be pressed when F5 is pressed if the binding is to take effect. As usual, see the Command Reference for a more detailed description. NOTE: The key binding, and menu key equivalent functions are completely separate. If you define a menu that has a key equivalent, and also bind that combination of keys to some other function, e93 does not guarantee which will take precedence, only that one of them will be executed, and not both.
|