|
WikiDoc |
Bindings Quick Start
IntroductionKeyboard shortcuts are handled in AlphaX via the concept of binding. A binding is an abstraction for the association of a key combination with some action to execute:
The creation and manipulation of bindings is handled, in AlphaTcl scripts, by the [binding] command. Menu items can also be associated with some action. Typically a menu item command is invoked when the menu item is selected with the mouse in a menu. But menu items often propose a keyboard equivalent. The keyboard equivalents must also be defined using the [binding] command. The fact that a key equivalent is displayed as a reminder in the menus is just a convenience. To keep things consistent and simple, AlphaX takes care of displaying the keyboard equivalents: the developer of Alpha packages does not have to worry about this. To have a keyboard equivalent drawn for a particular menu item, two conditions are required:
AlphaX automatically detects when these conditions are met and displays the key combination defined by the binding appropriately. Simple bindingThe syntax of the [binding] command is explained in details on the
Binding Command page of this wiki. Here is a simple example
which binds the
binding create {c 'N'} "new"
A menu item can also be defined to trigger the [new] Tcl proc. This is done with the [menuItem set] command:
menuItem set $menu $index -command "new"
where $menu represents the token of the menu and $index the
index of the menu item. See the
MenuItem Command page on
this wiki. Once the command is attached to the menu item, AlphaX
automatically displays the Composite bindingA composite binding requires a prefix combination. This prefix
combination is bound to the [prefixChar] command which is a special command
defined by Alpha. When it is invoked, Alpha expects a second combination
to be entered and executes it if it is bound to some action.
For instance, to create a
binding create {z 'A'} prefixChar
binding create -prefix {z 'A'} {"" 'B'} someTclProc
AlphaX is also able to display a composite binding in its menus: it suffices that a menu item be attached to the same Tcl proc (someTclProc in the example above). Counted composite bindingA counted composite binding requires a prefix and a number to be entered
before the binding like, for instance, Disabling menu item bindingsThere are two ways of disabling the automatic lookup of menu item equivalents when a menu is opened:
Note that this affects the drawing of the keyboard equivalent but does not suppress the binding itself: the combination will still be executed when the user enters it via the keyboard. The only way to suppress a keyboard shortcut is to invoke the [binding delete] command. (add your comments here...) |
|
Edit -
History -
Print -
Recent Changes -
Search
Page last modified on October 29, 2007, at 06:59 AM
|
Hosted on
|