GrGetNextEvent()

Name

GrGetNextEvent() -- Get an event from the queue

Synopsis

void GrGetNextEvent ( GR_EVENT * ep );

Description

This function retrieves the next nano-X event from the event queue and returns the event in the caller supplied GR_EVENT structure. If the event queue is empty, the function will block until another event occurs.

Parameters

TypeNameDescription
GR_EVENT*epPointer to the caller supplied structure to receive the next event from the event queue.

Example

The following example shows a typical event loop. The first line of the infinite while loop will suspend the client application until an event is available in the event queue. Then the example switches on the event type calling the appropriate application function to process the event.

Example 2-1. Using GrGetNextEvent()

 
void typical_event_loop (void)
{
    GR_EVENT  event;

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

        case GR_EVENT_TYPE_BUTTON_DOWN:
            process_button_event ((GR_EVENT_BUTTON*) event);
            break;

        case GR_EVENT_TYPE_KEY_DOWN:
        case GR_EVENT_TYPE_KEY_UP:
            process_key_event ((GR_EVENT_KEYSTROKE*) event);
            break;

        case GR_EVENT_TYPE_SCREENSAVER:
            process_screensaver_event ((GR_EVENT_SCREENSAVER*) event);
            break;

        case GR_EVENT_TYPE_CLOSE_REQ:
            GrClose();
            exit (0);
        }
    }
}

See Also

GrSelectEvents(), GrGetNextEventTimeout(), GrCheckNextEvent(), GrPeekEvent(), GrMainLoop().