Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

dtk_process_events(3) [debian man page]

DTK_PROCESS_EVENTS(3)						Draw Toolkit manual					     DTK_PROCESS_EVENTS(3)

NAME
dtk_process_events, dtk_set_event_handler - Events processing SYNOPSIS
#include <dtk_event.h> typedef int (*DTKEvtProc)(dtk_hwnd, int, const union dtk_event*); void dtk_set_event_handler(dtk_hwnd wnd, DTKEvtProc handler); int dtk_process_events(dtk_hwnd wnd); DESCRIPTION
dtk_set_event_handler() set handler as the current event handler for the window wnd. handler is a function that has arguments in the fol- lowing order: * a reference of type dtk_hwnd to the window that has received the event. * the type ID of the event. * a pointer to a union dtk_event holding event-specific data (if not NULL) defined as follows: union dtk_event { struct dtk_keyevent key; struct dtk_mouseevent mouse; }; dtk_process_events() processes pending events in the event queues associated to the window referenced by wnd, i.e. for each event in the queue, it calls the event handler that has been set by dtk_set_event_handler(). dtk_process_events() returns if a event handler has returned 0 or if there is no more pending event in the queue. If dtk_set_event_handler() has never been called or called with handle as NULL, it use a minimalistic event handler that returns 0 (i.e. stop the loop) when pressing the close button on the window. The type ID of the event can be one of the following: DTK_EVT_REDRAW This event indicates that the whole window or parts of it must be redrawn. This may be caused by another window has been overlapped it or the window has been resized. If such an event is received, the event pointer passed to the handler will be NULL. DTK_EVT_QUIT This event indicates that the close button of the window has been clicked. The event pointer passed will be NULL. DTK_EVT_KEYBOARD Indicates that a key of the keyboard has been pressed or released. If such an event is received, the meaningfull member of the union dtk_event will be key which is defined as follows: struct dtk_keyevent { unsigned int state; /* pressed or released */ unsigned int sym; /* Symbolic code of the key */ unsigned int mod; /* modifiers key */ }; DTK_EVT_MOUSEBUTTON This event indicates that one of the mouse buttons has been pressed or released. If such an event is received, the meaningfull mem- ber of the union dtk_event will be mouse which is defined as follows: struct dtk_mouseevent { unsigned int button; /* button identifier */ unsigned int state; /* pressed or realeased */ unsigned int x; /* x-coordinate of the mouse position */ unsigned int y; /* y-coordinate of the mouse position */ }; DTK_EVT_MOUSEMOTION This is similar to the DTK_EVT_MOUSEBUTTON but indicates that the mouse has moved. Event data should also be accessed through mouse member but its button and state members will be meaningless. RETURN VALUE
dtk_set_event_handler() does not return value. dtk_process_events() returns 1 if there is no more pending event in the queue. It returns 0 if the processing loop has been interrupted by an event handler, i.e. the last event handler has returned 0. EPFL
2010 DTK_PROCESS_EVENTS(3)

Check Out this Related Man Page

SDL_Event(3)							 SDL API Reference						      SDL_Event(3)

NAME
SDL_Event - General event structure STRUCTURE DEFINITION
typedef union{ Uint8 type; SDL_ActiveEvent active; SDL_KeyboardEvent key; SDL_MouseMotionEvent motion; SDL_MouseButtonEvent button; SDL_JoyAxisEvent jaxis; SDL_JoyBallEvent jball; SDL_JoyHatEvent jhat; SDL_JoyButtonEvent jbutton; SDL_ResizeEvent resize; SDL_ExposeEvent expose; SDL_QuitEvent quit; SDL_UserEvent user; SDL_SysWMEvent syswm; } SDL_Event; STRUCTURE DATA
type The type of event active Activation event key Keyboard event motion Mouse motion event button Mouse button event jaxis Joystick axis motion event jball Joystick trackball motion event jhat Joystick hat motion event jbutton Joystick button event resize Application window resize event expose Application window expose event quit Application quit request event user User defined event syswm Undefined window manager event DESCRIPTION
The SDL_Event union is the core to all event handling is SDL, its probably the most important structure after SDL_Surface. SDL_Event is a union of all event structures used in SDL, using it is a simple matter of knowing which union member relates to which event type. Event type Event Structure SDL_ACTIVEEVENT SDL_ActiveEvent SDL_KEYDOWN/UP SDL_KeyboardEvent SDL_MOUSEMOTION SDL_MouseMotionEvent SDL_MOUSEBUTTONDOWN/UP SDL_MouseButtonEvent SDL_JOYAXISMOTION SDL_JoyAxisEvent SDL_JOYBALLMOTION SDL_JoyBallEvent SDL_JOYHATMOTION SDL_JoyHatEvent SDL_JOYBUTTONDOWN/UP SDL_JoyButtonEvent SDL_QUIT SDL_QuitEvent SDL_SYSWMEVENT SDL_SysWMEvent SDL_VIDEORESIZE SDL_ResizeEvent SDL_VIDEOEXPOSE SDL_ExposeEvent SDL_USEREVENT SDL_UserEvent USE
The SDL_Event structure has two uses o Reading events on the event queue o Placing events on the event queue Reading events from the event queue is done with either SDL_PollEvent or SDL_PeepEvents. We'll use SDL_PollEvent and step through an exam- ple. First off, we create an empty SDL_Event structure. SDL_Event test_event; SDL_PollEvent removes the next event from the event queue, if there are no events on the queue it returns 0 otherwise it returns 1. We use a while loop to process each event in turn. while(SDL_PollEvent(&test_event)) { The SDL_PollEvent function take a pointer to an SDL_Event structure that is to be filled with event information. We know that if SDL_PollEvent removes an event from the queue then the event information will be placed in our test_event structure, but we also know that the type of event will be placed in the type member of test_event. So to handle each event type seperately we use a switch statement. switch(test_event.type) { We need to know what kind of events we're looking for and the event type's of those events. So lets assume we want to detect where the user is moving the mouse pointer within our application. We look through our event types and notice that SDL_MOUSEMOTION is, more than likely, the event we're looking for. A little more research tells use that SDL_MOUSEMOTION events are handled within the SDL_MouseMotion- Event structure which is the motion member of SDL_Event. We can check for the SDL_MOUSEMOTION event type within our switch statement like so: case SDL_MOUSEMOTION: All we need do now is read the information out of the motion member of test_event. printf("We got a motion event. "); printf("Current mouse position is: (%d, %d) ", test_event.motion.x, test_event.motion.y); break; default: printf("Unhandled Event! "); break; } } printf("Event queue empty. "); It is also possible to push events onto the event queue and so use it as a two-way communication path. Both SDL_PushEvent and SDL_Peep- Events allow you to place events onto the event queue. This is usually used to place a SDL_USEREVENT on the event queue, however you could use it to post fake input events if you wished. Creating your own events is a simple matter of choosing the event type you want, setting the type member and filling the appropriate member structure with information. SDL_Event user_event; user_event.type=SDL_USEREVENT; user_event.user.code=2; user_event.user.data1=NULL; user_event.user.data2=NULL; SDL_PushEvent(&user_event); SEE ALSO
SDL_PollEvent, SDL_PushEvent, SDL_PeepEvents SDL
Tue 11 Sep 2001, 22:59 SDL_Event(3)
Man Page