Progress
Language Tutorial
for Character
Responding to Events
For every widget, there is always a default response for each possible event. The default response for pressing TAB with most widgets is to move input focus to the next enabled widget. The default response for pressing a character key when a fill-in field has focus is to display that character in the field.
The default response for many events is no response. As mentioned earlier, some keystrokes with certain widgets don’t make sense. Therefore, Progress ignores these events. Remember that for every widget-event pair, Progress executes the default response, even though that response may be no response.
Now you need a way to program new responses for widget-event pairs. For example, in the “Hello Progress World!” application, suppose you want to display a message as soon as input focus moves to Field3. The Progress programming structure for this task consists of an ON statement and a block of code called a trigger. The ON statement is the device that establishes the condition that executes a trigger. A trigger is the code that Progress executes only when a specified widget receives a specified event. A trigger is a programmed response. A programmed response occurs before the default response.
Using Triggers
Follow these steps to create a trigger:
The following code points out the new language element:
Notice the new language element in the example, the ON statement. The ON statement sets up the trigger. In the example, ENTRY is the event and Field3 is the widget. (ENTRY is an event that occurs when the user or the application gives input focus to a widget.) The MESSAGE statement is the trigger that occurs when Field3 receives the ENTRY event.
NOTE: By default, window widgets reserve space at the bottom of the window to display messages from Progress and your application. The MESSAGE statement automatically outputs text enclosed in quotes to the message area.This is a partial syntax for the ON statement. (For complete syntax descriptions, see the Progress Language Reference or access the On-line Language Reference module of the help system.)
The following table describes the elements of the ON statement:
Defining triggers is part of the basic Progress code template. Adding triggers to the basic template gives you this new coding template:
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |