Using the AButton Control  to Perform Actions

There are several ways to allow a user to interact with a test program. One of the simplest is the AButton control, which the user clicks to perform actions. To place the AButton control in your form, click on the control in the toolbar AButton control, and then drag it within your form to size the control.

The AButton control's appearance can be customized to display simple text instructions or a picture image to help the user understand its function. The test programmer can place code in the button's OnClick() event to perform any desired action.

Configuring the AButton

The AButton control can be customized using the Properties window. The Caption property is on the Control tab of the Properties window. By setting the Caption property, you can set the label that will appear on the button.

From ATEasy v6, new support for multiple lines text and word wrap for the Caption property is automatically applied; that is, if the button height is big enough to include multi line text, it will be displayed as multi line, otherwise it will be displayed in a single line as truncated. This also applied for ARadioButton, ACheckBox.

You can also set the shape of the button, the alignment of the button text, and the width of the bevel and border. On the Picture tab, you can set a picture to go along with the text, or to replace the button text altogether.

Using the AButton

There are several ways to press a button at run time:

btnTest.OnClick()

All these actions invoke the OnClick() event procedure.

An example

 

In this example of the OnClick event for abtn1, the form has a button with a caption, "Start the test." When the button is clicked, the message in the label changes to "Test started," and the button caption changes to "Stop test."

Procedure btnTest.OnClick(): Void Public

{

if lblMsg.Caption = "Waiting for test to start..." then

lblMsg.Caption = "Test started."

btnTest.Caption = "Stop test"

! Code to start test here.

else

lblMsg.Caption = "Waiting for test to start..."

btnTest.Caption = "Start the test"

! Code to stop test here.

endif

}

For more information on the properties of the AButton control, see AButton.