Progress
Language Tutorial
for Windows
User Input
Any type of interaction a user can have with a Progress application is called an event. Each user action, like pressing a mouse button, is a separate event. For example, typing new data into a fill-in field is actually a series of events. Each individual keystroke is a separate event.
When you program in Progress, think of the user interface as a tool for displaying data and receiving user events. Progress processes the user events and notifies your application so that your code can respond to the events.
Considering the number and combinations of ways that a user can interact with an interface, the task of receiving and responding to those events must seem daunting. However, the Progress programming model significantly simplifies this task for you. First, the low-level computer tasks of receiving events from a keyboard or mouse and notifying your application occur automatically with Progress. Second, sorting through the stream of events becomes easier once you understand that certain events go naturally with certain widgets. For example, while it makes perfect sense to type characters in a fill-in field widget, it does not make sense to type characters to a button widget. Therefore, fill-in fields accept keyboard character events and button widgets do not.
This widget-event pairing leads to the question: how do you know which widget is receiving events? The user can tell which widget receives events because of the cursor location or other visual cues that Progress and the operating system provide. Since you cannot predict the order in which the user will interact with your widgets, your code must be ready to respond to many events.
How does your code know which widget is receiving events? To begin with, a widget can receive events only after the application has enabled it to receive input. Of all the widgets that are enabled at any time, only one can receive events. When a widget is the current event receptor, it has input focus. The application or the user can designate a widget to have input focus. The application can assign input focus to an enabled widget programmatically. The user can assign input focus by selecting the desired widget. The concept of input focus is absolutely crucial to a Progress application.
User Controlled Input Focus
Follow these steps to observe how the user can control input focus:
- From the Procedure Editor, open the
lt-03-01.p
procedure. (Use the Open option on the File menu.) Don’t worry about trying to understand the code right now.- Choose Compile
Run. You now see the basic interface you saw in Figure 3–2:
![]()
Notice that the cursor is positioned in Field1. This cursor illustrates two points:
- Press TAB to move input focus among the fields. These actions illustrate the last important point about input focus: after startup, the location of input focus is normally controlled by the user. In other words, users can enter data into the fill-in fields in any order.
- Move input focus to Field3 and press RETURN to end the procedure.
- Press SPACEBAR to return to the Procedure Editor.
Because the user has more control of input focus, the user has more control of the application. The application’s job is to respond to the user’s events in a way that correctly interprets the user’s desires. Because of this reliance on events, this type of programming model is called event-driven programming.
Parts of a Progress Procedure
Now, examine the code for the procedure you just ran:
You can break up this code into four sections:
- The first part of a Progress procedure defines widgets. The three DEFINE VARIABLE statements create three new variables for text data (AS CHARACTER) and initialize them with a string (INITIAL " "). Progress displays variables or database fields as fill-in fields by default.
- The second part of a Progress procedure creates the user interface. The DISPLAY statement creates an interface that consists of the default window, blank lines (SKIP), fill-in fields, and labels for the fields (SIDE-LABELS). This DISPLAY statement also centers the widgets within the default window (CENTERED) and suppresses the default border that surrounds the widgets (NO-BOX).
- The third part of a Progress procedure enables the widgets of the user interface. The ENABLE statement turns on the widgets. By default, the first widget listed in an ENABLE statement gets initial input focus. Assigning input focus to Field1 means that Field1 receives events at startup.
- The fourth part of a Progress procedure blocks execution. Now that you have presented a complete interface and enabled it for the user, you have to pause the execution of the procedure to allow the user to interact with the interface. This process is called blocking. If you did not block, Progress would execute the code to the end of the file and end the procedure.
The WAIT-FOR statement is your primary tool for blocking execution. With it, you establish the condition that signals that the user has finished working with the current interface. In this case, if the user presses RETURN (WAIT-FOR RETURN) while input focus is in Field3 (OF Field3), then the procedure completes.
Every Progress procedure that interacts with the user follows this basic four-step process:
You explicitly code these four steps. Progress provides much of the additional functionality required to make this interface flexible and responsive to the user. For example:
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |