first previous next last contents


add_command name onval offval command

This adds a new command to an application. The name should be the menu pathname followed by fullstop followed by the name of the command to appear in the menu. So if the command is within a cascading menu the name will have several components broken down by fullstops, ending in the command name itself.

The onval and offval arguments control the states for which the command is to be enabled in.

The command argument is the command to execute when this menu item is selected. This is a single argument so Tcl quoting rules must be obeyed for multi-word commands. This command is evaluated (using the Tcl eval command) at the time of selecting the menu item. If the command is to contain references to variables, it is important to distinguish between variables expanded at the time of creating the menu item and the time of executing the menu item by backslashing the latter.

For example, the Gap4 "Quality" mode of the consensus output has the following specification.

add_command  {File.Calculate a consensus.quality}  8 10  {QualityDialog \$io}

Here the "quality" command is within the "Calculate a consensus" cascading menu which is within the "File" menu. It is enabled by bit 3 (a database containing data has been opened) and is disabled by bits 1 and 3 (the database has no data or busy mode is enabled). The command to run is QualityDialog $io. If we did not backslash the $io in this command the io variable would be expanded up at the time of creating the menus, say to "0". Then when the menu item is selected we would always execute QualityDialog 0 which is not the desired effect.

first previous next last contents
This page is maintained by staden-package. Last generated on 1 March 2001.