The first parameter of an event function is a pointer to a data structure. The event table in which an event function is installed determines what type of data structure the function receives. For example, a function installed in the form event table FMETP receives a pointer to the form structure, while an event function installed in the choice list event table CLETP receives a pointer to the choice list structure. Table 38.1 lists each event table and what the event functions in this event table are being passed.
Table 38.1: Data Passed to an Event Function
| Event Table | Type of Pointer Passed | Description |
| CLETP | CLISTPTR | Choice list being processed |
| DRAGETP | KEYCTRLPTR | Key control structure initialized by wn_drag() |
| FLDETP | FORMPTR | Data form being processed |
| FMETP | DFORMPTR | Data form being processed |
| HELPETP | HELPPTR | Help structure |
| LBOXETP | DFORMPTR | Data form being processed |
| MEMOETP | DFORMPTR | Data form being processed |
| MNETP | MFORMPTR | Menu form being processed |
| PUSHETP | DFORMPTR | Data form being processed |
| RADIOETP | DFORMPTR | Data form being processed |
| SRETP | DFORMPTR | Data form being processed |
| TTMEMOETP | DFORMPTR | Data form being processed |
| VIEWETP | KEYCTRLPTR | Key control structure initialized by mf_browse() or wn_browse() |
| SYSETP | KEYCTRLPTR | One of the above structures |
Event functions installed in the VIEWETP and DRAGETP event tables receive a pointer to a key control structure. The key control structure is a special structure that is created by Vermont Views before entering the input processing loop when viewing or dragging. The key control structure contains three members: one for a structure tag, one for a pointer to the window currently being operated on, and one for an action code. In the case of viewing, the window being pointed to must have an associated memory file or memory screen buffer.
The second parameter of an event function is the event structure itself. Most event functions do not need information about the event to perform their tasks. From the event structure passed to your event function, however, you can get information about the event that caused your function to be called.
The event structure is as follows:
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
The information placed into this structure depends on the type of event. This structure is created and filled in when the event is posted, and passed into your event function. Typically, type is set to one of the predefined Vermont Views event types, and wmsg and lmsg contain information that is specific to that event type.
The most common event type is AC_KEYPRESS. Event functions which are attached to a key receive an event structure of type AC_KEYPRESS. For events of this type, the following structure members are set in the event structure: type is set to AC_KEYPRESS, and wmsg is set to the keycode value of the key pressed. The lmsg structure member is not used and contains no meaningful data.
Event functions are normally associated with key events, which have the event type AC_KEYPRESS. If you are writing an event function that will be called in some other way (for example, by posting the event in your code), you may need to determine what information will be in the event structure. The information in Chapter 42, "Posting Events from Your Code," may be helpful. This chapter includes a table showing the event type, wmsg and lmsg values for each of the event types defined in Vermont Views.