|
WikiDoc |
The [binding] commandCommands.BindingCommand HistoryHide minor edits - Show changes to markup September 30, 2009, at 09:05 AM
by - Removed experimental
Changed line 3 from:
to:
January 01, 2008, at 02:20 PM
by -
Changed line 245 from:
to:
March 03, 2007, at 04:12 PM
by - Updated example in [binding list]
Changed line 155 from:
{cv 112 Tcl Tcl::doSomethingProc abcd}
to:
{cv 112 Tcl abcd Tcl::doSomethingProc ""}
March 01, 2007, at 10:39 AM
by - Added help string to output of [binding list] command
Changed lines 133-134 from:
made of the to:
made of the Changed lines 137-139 from:
Each element of the list returned by the [binding list] command is a sublist describing a particular key binding. The sublist contains 6 or 8 elements: to:
Each element of the list returned by the [binding list] command is a sublist describing a particular key binding. The sublist contains 6 or 8 elements: March 01, 2007, at 10:37 AM
by - Added help string to output of [binding list] command
Changed lines 133-134 from:
made of the to:
made of the Changed line 139 from:
a sublist describing a particular key binding. The sublist contains 5 or 7 to:
a sublist describing a particular key binding. The sublist contains 6 or 8 Added line 144:
Changed line 146 from:
to:
Added line 149:
February 16, 2007, at 01:30 PM
by - Modified syntax after removal of [action] command
Changed line 3 from:
to:
Changed line 11 from:
to:
Changed lines 25-26 from:
Bindings are now associated with actions defined with the [action] command (see the ActionCommand page on this wiki): this is a to:
Bindings are associated with Tcl procs (or Tcl code snippets): this is a Changed line 27 from:
actions using the new [menuItem] command (see the to:
Tcl procs using the new [menuItem] command (see the Changed lines 57-58 from:
to:
Added line 68:
Changed line 86 from:
binding create ?option value...? {modifiers key} action
to:
binding create ?option value...? {modifiers key} proc
Changed lines 90-91 from:
to:
Added line 93:
Added lines 95-96:
Deleted line 97:
Changed lines 105-109 from:
The [find] subcommandThis subcommand lets you find if a key binding already exists for a particular configuration of the parameters. If the binding exists, the command returns the token of the action it is associated with, otherwise it raises an error. The syntax is: to:
The [info] subcommandThis subcommand lets you get information about an existing key binding. The syntax is: Changed line 109 from:
binding find ?option value...? {modifiers key}
to:
binding info (command|help) ?option value...? {modifiers key}
Changed lines 111-112 from:
The possible options are -tag and -prefix which have the same meaning as with the [binding create] command. to:
The third argument indicates which info is desired. It can be one of the following keywords:
The possible options are -tag and -prefix which have the same meaning as with the [binding create] command. If the binding does not exist, the command raises an error. Changed lines 126-129 from:
the bindings satisfying the specified options. The available options are:
to:
the bindings satisfying these options. The available options are:
Changed lines 138-142 from:
a sublist describing a particular key binding. The sublist contains 4 or 5 elements: the modifiers string (an empty string if there are no modifier specifications), the key code (decimal value), the token of the action, and the tag (an empty string if the binding is global). Finally, there will be two additional modifiers and key elements if the binding is composite and to:
a sublist describing a particular key binding. The sublist contains 5 or 7 elements:
The last two elements are present only if the binding is composite and Changed line 149 from:
For instance, if a binding were created like this: to:
For instance, if a binding is created like this: Changed line 151 from:
binding create -tag Tcl {cv 112} action1234
to:
binding create -creator "abcd" -tag Tcl {cv 112} Tcl::doSomethingProc
Changed line 153 from:
the returned sublist would be to:
the returned sublist will be Changed line 155 from:
{cv 112 action1234 Tcl}
to:
{cv 112 Tcl Tcl::doSomethingProc abcd}
Changed lines 157-158 from:
This command can be used to find if there exists some key bindings pointing to a particular action. For instance: to:
This command can be used to find if there exists some key bindings pointing to a particular Tcl proc. For instance: Changed line 161 from:
binding list -action action1234 to:
binding list -command Tcl::doSomethingProc Added lines 163-175:
The command can also be useful with the -creator option to identify certain groups of bindings. For instance, a package might want to keep track of the bindings it defines: if the bindings were declared with a -creator option like this
binding create -creator "ABCD" {modifiers key}
the package can expose them later via:
binding list -creator "ABCD"
Changed line 301 from:
binding create -prefix {oz 'B'} {"" 'Z'} actionToken
to:
binding create -prefix {oz 'B'} {"" 'Z'} someProc
Changed lines 303-305 from:
The ctrl-opt-B Z binding would trigger the action designated by actionToken. to:
The ctrl-opt-B Z binding would trigger the Tcl proc designated by someProc. Changed lines 310-311 from:
set theAction [action create -script prefixChar]
binding create {oz 'B'} $theAction
to:
binding create {oz 'B'} prefixChar
Changed line 314 from:
the action designated by actionToken. to:
the code designated by someProc. Changed lines 394-397 from:
# Define a few actions to:
proc bindingActionProc {idx} {
alertnote "Command $idx triggered"
}
# Define a few commands
Changed line 399 from:
set act$i [action create -script {alertnote "This is act$i"} -help "help string about act$i"]
to:
set cmd$i "test::bindingActionProc $i" Changed lines 403-405 from:
binding create {co 65} $act1
binding create {cz 65} $act2
binding create {coz 65} $act3
to:
binding create -help "opt-cmd-A combo" {co 65} $cmd1
binding create -help "ctrl-cmd-A combo" {cz 65} $cmd2
binding create -help "ctrl-opt-cmd-A combo" {coz 65} $cmd3
Changed lines 408-411 from:
binding create {co 76} $act4
binding create -tag Tcl {co 76} $act5
binding create -tag Python {co 76} $act6
binding create -tag Ruby {co 76} $act7
to:
binding create {co 76} $cmd4
binding create -tag Tcl {co 76} $cmd5
binding create -tag Python {co 76} $cmd6
binding create -tag Ruby {co 76} $cmd7
Changed lines 414-416 from:
binding create {cozv F5} $act8
binding create -tag Tcl {cozv F5} $act9
binding create -tag Ruby {cozv F5} $act10
to:
binding create {cozv F5} $cmd8
binding create -tag Tcl {cozv F5} $cmd9
binding create -tag Ruby {cozv F5} $cmd10
Changed line 419 from:
binding create {v Help} $act11
to:
binding create {v Help} $cmd11
Changed line 433 from:
binding list -action $act1 to:
binding list -command $cmd1 Changed lines 435-436 from:
# Find the action associated with the opt-cmd-L combination in Ruby mode
binding find -tag Ruby {co 76}
to:
# Find the command associated with the opt-cmd-L combination in Ruby mode
binding info command -tag Ruby {co 76}
Changed lines 438-441 from:
# Delete the previous combination to:
# Retrieve the help associated with a binding
binding info help {co 65}
# Delete the previous combination
February 08, 2007, at 04:07 PM
by - Updated doc for [binding list] command
Changed line 136 from:
the tag (an empty string if the binding is global). Additionnally, there to:
the tag (an empty string if the binding is global). Finally, there February 08, 2007, at 04:05 PM
by - Updated doc for [binding list] command
Changed line 137 from:
will be a {modifiers key} element if the binding is composite and to:
will be two additional modifiers and key elements if the binding is composite and Changed lines 152-157 from:
See examples in the Examples section below. Note that character code bindings corresponding to a letter are case insensitive: they are stored internally using the code of the lowercase letter even if the definition was invoked using an uppercase letter. So, if a binding has been defined for 'A' (ASCII 65), the value returned by [binding list] will be 97 which is the ASCII code for 'a'. to:
See examples in the Examples section below. Note that character code bindings corresponding to a letter are case insensitive: they are stored internally using the code of the lowercase letter even if the definition was invoked using an uppercase letter. On output, all the character code bindings corresponding to a printable character are written with this character (uppercase form between single quotes); the other bindings (including virtual key bindings) are represented by the decimal value of the key. So, if a binding has been defined for 'a', the value returned by [binding list] will be 'A'. February 06, 2007, at 01:12 PM
by - Added glyph codes section (moved from the menuItem page)
Added line 4:
Changed lines 16-17 from:
to:
Changed lines 63-68 from:
to:
Added lines 288-361:
Glyph codesHere is a table of the numerical constants which can be used with the -glyph option. Glyphs are used with virtual keycode bindings (not with character code bindings) to represent keys which are not associated with a single letter or symbol on the keyboard. Most of these values have already been listed in the table of the Symbolic key names section above. Virtual keycode bindings attached to a key corresponding to a simple letter or symbol are represented by this letter or symbol. You would not normally have to invoke this option unless you wanted to modify the default glyph automatically provided by Alpha. For instance, in some circumstances, you might want to replace the Left Arrowglyph by the Left Arrow Dashed glyph.
Changed line 363 from:
Examplesto:
February 06, 2007, at 11:03 AM
by - Updated for 8.1a5d4
Changed lines 1-3 from:
to:
(:title The [binding] command:)
Changed line 6 from:
to:
Changed lines 12-15 from:
to:
Added line 22:
Changed lines 30-31 from:
the [bind] command. to:
the old [Bind] command. Changed lines 36-41 from:
A key binding is uniquely determined by these parameters: the code is a required parameter, and by default, it is interpreted as a character code. The other parameters are optional. If the tag is empty or unspecified, the binding is global. If the modifiers are not specified, it is assumed that it is the Command key. to:
A key binding is uniquely determined by these parameters. The code and the modifiers are required parameters. The other parameters are optional. By default, a code is interpreted as a character code. If the tag is empty or unspecified, the binding is global. Changed lines 49-58 from:
Parameter optionsThe optional parameters described above are specified in the various subcommands of the [binding] command by the following switches:
Binding subcommandsThe [create] subcommandThis subcommand creates a new binding or redefines an already existing binding. It accepts a few options. The complete syntax is: to:
Specifying a key comboMany subcommands of the [binding] command take a command key argument of the form Changed line 52 from:
binding create ?option value...? commandKey action to:
{modifiers key}
Changed lines 54-59 from:
The [binding create] command has two required arguments:
The options have been described in the preceding section. The [delete] subcommandThis subcommand lets you delete a key binding. The syntax is: to:
This argument describes a key combination. It is a two elements Tcl list:
The modifiers are specified as a string made of some of the following letters:
The modifier string must be an empty string if no modifiers are associated with the key combo. There are three ways of specifying the main key:
Note that character code bindings are case insensitive. So Binding subcommandsThe [create] subcommandThis subcommand creates a new binding or redefines an already existing binding. It accepts a few options. The complete syntax is: Changed line 84 from:
binding delete ?option value...? commandKey to:
binding create ?option value...? {modifiers key} action
Changed lines 86-100 from:
The options are the same as with the [binding create] command. to:
The command has two required arguments:
Here are the currently defined options:
The [delete] subcommandThis subcommand lets you delete a key binding. The syntax is:
binding delete ?option value...? {modifiers key}
The possible options are -tag and -prefix which have the same meaning as with the [binding create] command. Changed line 103 from:
particular configuartion of the parameters. If the binding exists, the to:
particular configuration of the parameters. If the binding exists, the Changed line 107 from:
binding find ?option value...? commandKey to:
binding find ?option value...? {modifiers key}
Changed lines 109-110 from:
The options are the same as with the [binding create] command. to:
The possible options are -tag and -prefix which have the same meaning as with the [binding create] command. Changed line 115 from:
binding list ?commandKey? to:
binding list ?option value...? Changed lines 117-125 from:
If the commandKey argument is specified only those bindings involving this key code will be returned. Each element of the list returned by the [binding list] command is a sublist describing a particular key binding. The sublist contains 4 or 5 elements: the key code, the modifiers constant, a boolean value telling if it is a virtual key, the token of the action, and the tag (if any). ExamplesHere are a few basic examples which can be executed one by one in the Tcl shell in AlphaX: to:
One can specify some options to restrict the returned list to only the bindings satisfying the specified options. The available options are:
This allows you to specify key codes or modifiers separately. The value
of the -key option can be either a numeric value or a letter enclosed
between single quotes. The value of the -modifiers option is a string
made of the Each element of the list returned by the [binding list] command is a sublist describing a particular key binding. The sublist contains 4 or 5 elements: the modifiers string (an empty string if there are no modifier specifications), the key code (decimal value), the token of the action, and the tag (an empty string if the binding is global). Additionnally, there will be a {modifiers key} element if the binding is composite and has been defined with a -prefix option. For instance, if a binding were created like this: Changed lines 139-168 from:
# Define a few actions
for {set i 1} {$i < 10} {incr i} {
set act$i [action create -script {alertnote "This is act$i"} -help "help string about act$i"]
}
# Bindings to letter A (resp opt-cmd-A, ctrl-cmd-A, and ctrl-opt-cmd-A)
binding create -modifiers 2 65 $act1
binding create -modifiers 4 65 $act2
binding create -modifiers 6 65 $act3
# Bindings to letter L
binding create -modifiers 2 76 $act4
binding create -modifiers 2 -tag Tcl 76 $act5
binding create -modifiers 2 -tag Python 76 $act6
binding create -modifiers 2 -tag Ruby 76 $act7
# A virtual keycode binding attached to opt-F5 (the keycode of F5 is 96)
binding create -virtual 1 -modifiers 10 96 $act8
# Get a list of all the bindings
binding list
# Get a list of all the bindings associated with letter L
binding list 76
# Find the action associated with the opt-cmd-L combination in Ruby mode
binding find -modifiers 2 -tag Ruby 76
# Delete the previous combination
binding delete -modifiers 2 -tag Ruby 76
to:
binding create -tag Tcl {cv 112} action1234
Added lines 141-334:
the returned sublist would be
{cv 112 action1234 Tcl}
This command can be used to find if there exists some key bindings pointing to a particular action. For instance:
binding list -action action1234
See examples in the Examples section below. Note that character code bindings corresponding to a letter are case insensitive: they are stored internally using the code of the lowercase letter even if the definition was invoked using an uppercase letter. So, if a binding has been defined for 'A' (ASCII 65), the value returned by [binding list] will be 97 which is the ASCII code for 'a'. Character codes vs. virtual keycodesA keyboard equivalent may be either a character code or a virtual keycode. Only one is used by the application at any given time: a virtual keycode binding always has precedence over a character code binding. Here is a list of the main virtual keycodes:
You can obtain the value of any virtual keycode using the Key Codes... command found is the Ascii Etc submenu of the Tools menu. Note that zero is a valid virtual keycode. Symbolic key namesHere is the list of the predefined symbolic names which can be used to specify a virtual key binding. These values are case insensitive, so one can use HOME, home, Home indifferently. The following table gives the symbolic names, the corresponding key codes and the values of the glyph automatically associated by default by Alpha (unless the -glyph option was specified):
In the case of key pad bindings, there is no glyph provided by the system. Alpha uses the character glyph instead. Composite bindingsThe -prefix option can be used in the binding create command to define composite bindings. Its value is a two-elements Tcl list of the form {modifiers key} with the same meaning as for the main key argument. For instance, in order to define the binding ctrl-opt-B Z (which means, first press ctrl-opt-B, then press Z), the instruction is:
binding create -prefix {oz 'B'} {"" 'Z'} actionToken
The ctrl-opt-B Z binding would trigger the action designated by actionToken. For this mechanism to work, the simple ctrl-opt-B binding must also be defined and must be attached to the [prefixChar] core command. For instance:
set theAction [action create -script prefixChar]
binding create {oz 'B'} $theAction
The [prefixChar] core command takes care of waiting for the second part of the binding to be entered (here the letter Z) and then to execute the action designated by actionToken. ExamplesHere are a few basic examples which can be executed one by one in the Tcl shell in AlphaX:
# Define a few actions
for {set i 1} {$i < 12} {incr i} {
set act$i [action create -script {alertnote "This is act$i"} -help "help string about act$i"]
}
# Bindings to letter A (resp opt-cmd-A, ctrl-cmd-A, and ctrl-opt-cmd-A)
binding create {co 65} $act1
binding create {cz 65} $act2
binding create {coz 65} $act3
# Bindings to letter L
binding create {co 76} $act4
binding create -tag Tcl {co 76} $act5
binding create -tag Python {co 76} $act6
binding create -tag Ruby {co 76} $act7
# A virtual keycode binding attached to opt-F5
binding create {cozv F5} $act8
binding create -tag Tcl {cozv F5} $act9
binding create -tag Ruby {cozv F5} $act10
# The Help key
binding create {v Help} $act11
# Get a list of all the bindings
binding list
# Get a list of all the bindings associated with letter L
binding list -key 76
# Get a list of all the bindings using opt-cmd
binding list -modifiers "co"
# Get a list of all the bindings defined in Ruby mode
binding list -tag Ruby
# Get a list of all the opt-cmd bindings in Ruby mode
binding list -modifiers "co" -tag Ruby
# Get a list of all the bindings attached to act1
binding list -action $act1
# Find the action associated with the opt-cmd-L combination in Ruby mode
binding find -tag Ruby {co 76}
# Delete the previous combination
binding delete -tag Ruby {co 76}
Changed lines 336-337 from:
(add your comments here...) to:
(add your comments here...) January 23, 2007, at 04:51 PM
by - New [binding] command
Added lines 1-125:
IntroductionThe [binding] command lets you create and manipulate key bindings in Alpha. The [binding] command is a proposed replacement for the old [bind] (or [Bind]) command. Bindings are now associated with actions defined with the [action] command (see the ActionCommand page on this wiki): this is a characteristic they share with menu items which can also be associated with actions using the new [menuItem] command (see the MenuItemCommand page on this wiki). The purpose of this new approach is to resolve the conflictual situations caused by key combinations defined directly by menu definitions or by an explicit call to the [bind] command. A key binding is defined by the following attributes:
A key binding is uniquely determined by these parameters: the code is a required parameter, and by default, it is interpreted as a character code. The other parameters are optional. If the tag is empty or unspecified, the binding is global. If the modifiers are not specified, it is assumed that it is the Command key. SynopsisThe formal syntax of the [binding] command is: binding subcommand ?options? The possible subcommands are described below. Depending on the subcommand, various options can be additionnally specified. Parameter optionsThe optional parameters described above are specified in the various subcommands of the [binding] command by the following switches:
Binding subcommandsThe [create] subcommandThis subcommand creates a new binding or redefines an already existing binding. It accepts a few options. The complete syntax is:
binding create ?option value...? commandKey action
The [binding create] command has two required arguments:
The options have been described in the preceding section. The [delete] subcommandThis subcommand lets you delete a key binding. The syntax is:
binding delete ?option value...? commandKey
The options are the same as with the [binding create] command. The [find] subcommandThis subcommand lets you find if a key binding already exists for a particular configuartion of the parameters. If the binding exists, the command returns the token of the action it is associated with, otherwise it raises an error. The syntax is:
binding find ?option value...? commandKey
The options are the same as with the [binding create] command. The [list] subcommandThis subcommand returns a list of the currently existing key bindings. The syntax is: binding list ?commandKey? If the commandKey argument is specified only those bindings involving this key code will be returned. Each element of the list returned by the [binding list] command is a sublist describing a particular key binding. The sublist contains 4 or 5 elements: the key code, the modifiers constant, a boolean value telling if it is a virtual key, the token of the action, and the tag (if any). ExamplesHere are a few basic examples which can be executed one by one in the Tcl shell in AlphaX:
# Define a few actions
for {set i 1} {$i < 10} {incr i} {
set act$i [action create -script {alertnote "This is act$i"} -help "help string about act$i"]
}
# Bindings to letter A (resp opt-cmd-A, ctrl-cmd-A, and ctrl-opt-cmd-A)
binding create -modifiers 2 65 $act1
binding create -modifiers 4 65 $act2
binding create -modifiers 6 65 $act3
# Bindings to letter L
binding create -modifiers 2 76 $act4
binding create -modifiers 2 -tag Tcl 76 $act5
binding create -modifiers 2 -tag Python 76 $act6
binding create -modifiers 2 -tag Ruby 76 $act7
# A virtual keycode binding attached to opt-F5 (the keycode of F5 is 96)
binding create -virtual 1 -modifiers 10 96 $act8
# Get a list of all the bindings
binding list
# Get a list of all the bindings associated with letter L
binding list 76
# Find the action associated with the opt-cmd-L combination in Ruby mode
binding find -modifiers 2 -tag Ruby 76
# Delete the previous combination
binding delete -modifiers 2 -tag Ruby 76
(add your comments here...) |
|
Edit -
History -
Print -
Recent Changes -
Search
Page last modified on September 30, 2009, at 09:05 AM
|
Hosted on
|