GR_EVENT

Name

GR_EVENT -- Generic event structure

Synopsis

typedef union 
{
    GR_EVENT_TYPE       type;
    GR_EVENT_ERROR      error;
    GR_EVENT_GENERAL    general;
    GR_EVENT_BUTTON     button;
    GR_EVENT_KEYSTROKE  keystroke;
    GR_EVENT_EXPOSURE   exposure;
    GR_EVENT_MOUSE      mouse;
    GR_EVENT_FDINPUT    fdinput;
    GR_EVENT_UPDATE     update;
} GR_EVENT;
  

Description

The GR_EVENT structure is used to retrieve event information from the nano-X event queue. When you pull an event out of the event queue you don't know what type of event it is until after you have the event. Various events are different sizes, this structure is a union of all event types. Since this structure is a union, it is guarenteed to be large enough to hold the largest possible event when you get an event from the event queue.

The type field identifies the structure type. After receiving an event it is common for an application to switch on type.

Example 1. GR_EVENT Usage

GR_EVENT  event;

while (1)
{
    GrGetNextEvent (&event);
    switch (event.type)
    {
    case GR_EVENT_TYPE_EXPOSURE:
        do_something ((GR_EVENT_EXPOSURE*) event);
        break;

    case GR_EVENT_TYPE_BUTTON_DOWN:
        do_something_else ((GR_EVENT_BUTTON*) event);
        break;
    }
}
  

Fields

TypeNameDescription
GR_EVENT_TYPE typeThe type of event that this structure corresponds too.
GR_EVENT_ERROR errorAdditional event data, if the event type is GR_EVENT_TYPE_ERROR.
GR_EVENT_GENERAL generalAdditional event data, if the event type is GR_EVENT_TYPE_CLOSE_REQ, GR_EVENT_TYPE_MOUSE_EXIT, GR_EVENT_TYPE_MOUSE_ENTER, GR_EVENT_TYPE_FOCUS_OUT or GR_EVENT_TYPE_FOCUS_IN.
GR_EVENT_BUTTON buttonAdditional event data, if the event type is GR_EVENT_TYPE_BUTTON_UP or GR_EVENT_TYPE_BUTTON_DOWN.
GR_EVENT_KEYSTROKE keystrokeAdditional event data, if the event type is GR_EVENT_TYPE_KEY_DOWN or GR_EVENT_TYPE_KEY_UP.
GR_EVENT_EXPOSURE exposureAdditional event data, if the event type is GR_EVENT_TYPE_EXPOSURE.
GR_EVENT_MOUSE mouseAdditional event data, if the event type is GR_EVENT_TYPE_MOUSE_ENTER, GR_EVENT_TYPE_MOUSE_EXIT, GR_EVENT_TYPE_MOUSE_MOTION or GR_EVENT_TYPE_Mouse_POSITION.
GR_EVENT_FDINPUT fdinputAdditional event data, if the event type is GR_EVENT_TYPE_FDINPUT.
GR_EVENT_UPDATE updateAdditional event data, if the event type is GR_EVENT_TYPE_UPDATE.