Progress
Programming
Handbook


Buttons

A button is a field-level widget that can be chosen by the user. Typically, you define a trigger to execute when the button is chosen. You can specify a text label for the button. You can also specify an image to be displayed in the button. Optionally, you can specify a second image to be displayed when the button is pressed down, and a third image to be displayed when the button is insensitive.

Also, in a graphical interface such as Windows, you can optionally specify ToolTips, a brief text message string that automatically displays when the mouse pointer pauses over a button widget for which a ToolTip value is defined. Although ToolTips can be defined for a variety of field-level widgets, including images and rectangles discussed later in this chapter, they are most commonly defined for button widgets. For more information on ToolTips and other Windows interface design options, see Interface Design."

In a character interface, a button appears as the label enclosed in angle brackets (< >). Any image you specify for the button is ignored in a character interface.

The user chooses a button by clicking on it with the mouse SELECT button or by positioning to it with the TAB or ARROW–KEYS and pressing either SPACEBAR or ENTER.

The following procedure defines two buttons:

p-but1.p
DEFINE VARIABLE cnt AS INTEGER.
DEFINE BUTTON count-button LABEL "Show Count".
DEFINE BUTTON quit-button LABEL "Quit".

FORM
   count-button quit-button
   WITH FRAME button-frame.
FORM
   cnt VIEW-AS TEXT LABEL "Customer count"
   WITH FRAME cnt-frame SIDE-LABELS.

ON CHOOSE OF count-button DO:
     HIDE FRAME cnt-frame.
     cnt = 0.
     FOR EACH customer:
         cnt = cnt + 1.
     END.
     DISPLAY cnt WITH FRAME cnt-frame.
END.

ENABLE count-button quit-button WITH FRAME button-frame.
WAIT-FOR CHOOSE OF quit-button 
      OR WINDOW-CLOSE OF CURRENT-WINDOW. 

The example defines two buttons, puts them in a frame, and defines a trigger to execute when the first button is chosen. The second button is referenced in the WAITFOR statement. When you run this code and choose countbutton, the trigger counts the number of customers.

When you choose QUIT, the WAITFOR statement completes terminating the procedure.

At run time, you can use attributes such as AUTOENDKEY, AUTOGO, and LABEL to query or change the button’s characteristics.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095