Documentation

Introduction to Buttons

Combining the concepts of aliases, triggers, and variables are Buttons. Buttons not only make it easier for novice users to use these features, but provides significant functionality to power users that is not found in basic Telnet clients. Buttons can be clicked to execute a command, their caption can display the value of a variable, and they can act as a toggle to turn a feature (like triggers) on and off easily.

To define a button, right click on the button you wish to edit, or select Make Button from the Action menu. There are several types of buttons including: push buttons and toggle buttons. A push button is clicked to execute a command and releases as soon as you release the mouse. A toggle button changes between being off (up) or on (down).  You can  assign the name of a variable to the Variable field and the variable will contain the state of the button (0 for up/off, 1 for down/on). A Multistate button can have multiple captions and commands, and looks like a pull-down menu button. A menu button is similar to a multistate button, but simply points to a special menu class where the menu commands are defined, rather than defining the multiple commands within the button itself.

In the Caption, enter the text you wish to display on the face of the button when the button is in its normal, off position. The next field is for the script to execute when the button is pressed.

For a toggle button, the button will contain a second "state".  Click the sample button above the script editor to toggle it and edit this second state, or select the second state from the tree view on the left.  The Caption for the second state is displayed on the button when it is pressed (on).  The Script for the second state is executed when the pressed button is toggled off.

The value of the caption fields are evaluated, so you can put an expression containing variables and the result will be displayed on the button.

Selecting the Options tab at the bottom will show more properties of the button.  The Expr field is used to externally control the state of the button with any expression. You can do this with just the Variable (e.g. if you assign 1 to the variable in the Variable field, the button will activate itself, if you assign 0 to this variable the button will deactivate itself). However, the Expr field allows greater control as to whether the button is pressed or not. If the expression in the Expr field is true, the button is in the On state (pressed). If the expression in the Expr field is false, the button is in the Off state (released).

So, how about an example? In the Introduction to Triggers we created an ErrorTrig trigger. We can make this trigger much more user friendly by using it with a button. Select Make Button from the Action menu.  Click the Type field and select Toggle from the dropdown list.   In the Caption field, enter the text Errors off. In the Script field enter #t+ ErrorTrig. Click the sample button above the Caption field to toggle it, then enter Errors on in the caption field and #t- ErrorTrig into the Script field.   Click the Options tab and in the Variable field, enter ErrorTrig. Click OK to save the button definition. Now you have a button labeled "Errors off", and it is currently off. Click the button. The command #t+ ErrorTrig is executed and now the trigger for capturing errors has been enabled.  Any line from the server containing "Error" will now be stored into the @LastError variable. Note that the button now appears in the On state (is pressed in) and has the caption "Errors on". This gives you the visual clue that your ErrorTrig trigger is enabled so that you don't forget. Click the button again. The #t- ErrorTrig command is executed and your trigger is now disabled.  The button now appears in the Off position. Now you don't have to waste two keys on the keyboard to turn your ErrorTrig trigger on and off, and in addition you have a nice visual clue as to whether your trigger is active or not. Try to beat this in a text-based Telnet client!

Advanced Settings

In the Options tab you can control many attributes of your buttons. You can set the color of the button, change the size or location, and assign a graphic image to the button. There are over 100 predefined images built into TeSSH that you can access by clicking the down-arrow button on the right-side of the bitmap field. Buttons can have their icon to the left of the caption, or on top of the caption. Buttons can also be displayed using "Explorer" style which means they don't normally display a bevel around the edge of the button until the user moves the mouse over the button. This allows you to create button bars that can be very complex.

You can also assign a variable name to a button to keep track of the button state. A button that is off has a value of zero, and a button that is pushed in has a value of one. In addition to setting the value of the variable to the current button state, you can control the button by setting this variable in a script. For example, if you have the variable named "State" assigned to the button, and then do "state=1" the button will get pushed in.

The Expr field is similar to the Variable field, but specifies a full expression used to determine the state of the button. For example, the expression "@LastError = 401" can be used. The button will be pressed in whenever the variable @LastError has the value of "401". Clicking the button will have no effect...the button is now controlled by this expression value.

Multi-State Buttons

In addition to toggle buttons and push buttons, you can create "multi-state" buttons. These buttons have a menu associated with them. When you click on the button, the menu appears and you can select an item from the menu. Each item in the menu can correspond to a command, a new caption for the button, and/or a new color for the button.

In the Create Button dialog, select the Multi-state button Type, and then use the New/New Button State button on the toolbar to add a new state to the button. In addition to the different menu items, the button has a main caption state which specifies the default caption, command, and color for the button. Select the state you wish to change in the pulldown box, and then enter the caption for this state, along with the command you want to execute.

Multi-state buttons can also set variables just like toggle buttons. The default state has a value of zero, with the selectable menu items starting with a value of one.

Instead of defining the states and commands of a button directly, you can point to an existing menu class. Simply select the Menu button type, and enter the name of the menu class into the Command Script field for the button. Using this method, you can share common menu definitions between buttons and popup menus. See the Menus topic for more details.

Add comment

Login or register to post comments