GUI ScreenIO for Windows

 ScreenIO.com


Events - What Caused GUI ScreenIO to Return

Whenever GUI ScreenIO returns to your program, it tells you why in the field panel-EVENT-ID.  

What causes events?

Events can be triggered by a number of happenings; 

Event names

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.

Important Note: 

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.

Why does GUI ScreenIO use 88-level items for events?

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.

*                         :---------------------------------------
* ------------------------: Events returned in response to menu
*                         : or toolbar selections, buttons, etc.
*                         :---------------------------------------

       10  panel-EVENT-ID                 PIC S9(4) COMP-5.
         88  panel-EVENT-AUTO-RETURN      VALUE 0.
         88  panel-EVENT-INACTIVATED      VALUE 8901.
         88  panel-EVENT-ACTIVATED        VALUE 8900.
         88  panel-EVENT-CLOSE-WINDOW     VALUE 8003.
         88  panel-EVENT-CLOSE-AND-STOP   VALUE 8010.
         88  panel-MY-PUSHBUTTON          VALUE 1.

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 Events and Programming Actions

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.

Suggestion: Use EVALUATE to handle events

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.

     CALL 'GS' USING panel-1
                     panel-2
                     panel-3
                     panel-4

* ------------------------: Examine the event to see why it returned,
*                         : and do what was requested.

     EVALUATE TRUE
       WHEN panel-BUTTON-OK
         PERFORM OK-ROUTINE

       WHEN panel-BUTTON-CANCEL
         PERFORM CANCEL-ROUTINE

*                         : Ignore events you don't want to handle.
       WHEN OTHER
         CONTINUE

     END-EVALUATE


© 2000-2019 Norcom, all rights reserved 

TOC

Send feedback to Norcom