GUI ScreenIO for Windows |
Whenever GUI ScreenIO returns to your program, it tells you why in the field panel-EVENT-ID.
Events can be triggered by a number of happenings;
All possible events that can occur are defined as 88-level items in your panel copybook. There are several standard events that are assigned names by the GUI ScreenIO panel editor.
You assign your own names to events that you define (such as menu selections, or pushbutton events). This makes your code very readable.
You should Never! Never! Never! refer directly to panel-EVENT-ID when you evaluate events, because the numbers assigned to events by the panel editor are arbitrary and may change.
Always use the 88-level names to evaluate events. This also makes your program much more readable, particularly because YOU assign the names to events that you define.
We designed GUI ScreenIO to use 88-level items for this kind of thing so that all of the information you needed to handle a panel in your program is contained in the panel copybook. All you need to do is to refer to the 88-level names.
All of the possible values that could be returned are defined beneath this field in 88-level items. This makes it very easy to interpret them, since it's all right in front of you.
Here's an example from a panel copybook. The names assigned to events are always prefaced by the panel name so that they are unique; this eliminates problems if a program contains more than one panel.
*
:---------------------------------------
|
In this example, the first five event IDs are standard events which are present on all panels. panel-MY-PUSHBUTTON is the event that will be returned if the user triggers the panel object that is assigned this event. In this case, it's assigned to a pushbutton.
Standard Event | Cause/Program response |
panel-your-event-name | The user triggered an event you defined for the panel by
selecting a menu item, pressing a button, triggering an automatic return
from a field ("hot" field), or some other event you defined.
You process the event appropriately by updating a file, adding or deleting a record, and so on. |
panel-EVENT-ACTIVATED | Not used. |
panel-EVENT-AUTO-RETURN | You set the display option panel-DO-DISPLAY-AND-RETURN when you called GUI ScreenIO, so GUI ScreenIO returned to your program automatically after updating the contents of your panel. |
panel-EVENT-CLOSE-AND-STOP | The user clicked the X box on the main window
(though Windows may send this event when it needs to force you to close
your application).
You should close your open files and terminate your application. Note: It is theoretically possible for any of your panels to receive this event at any time, though this rarely happens. It's still good programming practice to code your application so that it can properly handle this event on all of your panels. Alternatively, you can handle it in GS.Cob. |
panel-EVENT-CLOSE-WINDOW | The user clicked on the "X" box of a popup
window or property sheet.
You should call GUI ScreenIO to display the next panel that you wish to display, which is generally the base panel that was displayed prior to the popup, or a popup displayed prior to the current popup. Do NOT close the panel in your program, because it is not necessary! GUI ScreenIO will close the panel automatically when you redisplay a previously displayed panel. See Programming Rules for a discussion of how GUI ScreenIO knows when to close a panel. Note: Special rules apply if you are using multiple working-sets. |
panel-EVENT-INACTIVATED | Your application uses multiple working-sets, and the user
clicked on a panel in a different working-set than the current panel.
You should call GUI ScreenIO with the panel that the user wishes to activate. See Multiple Working-Sets. |
panel-EVENT-TIMEOUT | You specified a timeout value for your panel, and the
specified timeout has been triggered.
In a multiple-user application, this would usually happen when a user locked a record and then forgot about it, or walked away from the computer. You would generally treat it the same as if your user abandoned the transaction. You can also use timeouts to display a banner for a few seconds after the user launches your application. |
Because GS will only return events that you explicitly define when you create your panel (plus a couple of standard events common to all panels), you don't have to worry too much about the type of events it will return. You already know the possibilities.
We prefer to use EVALUATE for handling conditions; it's very clean and easy to read and maintain.
This code sample shows how we handle events using EVALUATE. It's far easier to read and maintain than IF-ELSE-END-IF logic, particularly if you have many potential events you need to handle.
* ------------------------: Display the panel.
* ------------------------: Examine the event to see why
it returned,
EVALUATE TRUE
WHEN panel-BUTTON-CANCEL
*
: Ignore events you don't want to handle.
END-EVALUATE |
© 2000-2019 Norcom, all rights reserved |