1DTK_PROCESS_EVENTS(3)         Draw Toolkit manual        DTK_PROCESS_EVENTS(3)
2
3
4

NAME

6       dtk_process_events, dtk_set_event_handler - Events processing
7

SYNOPSIS

9       #include <dtk_event.h>
10
11       typedef int (*DTKEvtProc)(dtk_hwnd, int, const union dtk_event*);
12
13       void dtk_set_event_handler(dtk_hwnd wnd, DTKEvtProc handler);
14       int dtk_process_events(dtk_hwnd wnd);
15

DESCRIPTION

17       dtk_set_event_handler()  set  handler  as the current event handler for
18       the window wnd. handler is a function that has arguments in the follow‐
19       ing order:
20
21        * a  reference  of  type  dtk_hwnd to the window that has received the
22          event.
23
24        * the type ID of the event.
25
26        * a pointer to a union dtk_event holding event-specific data  (if  not
27          NULL) defined as follows:
28
29              union dtk_event {
30                  struct dtk_keyevent key;
31                  struct dtk_mouseevent mouse;
32              };
33
34       dtk_process_events() processes pending events in the event queues asso‐
35       ciated to the window referenced by wnd, i.e.  for  each  event  in  the
36       queue,   it   calls   the   event   handler   that   has  been  set  by
37       dtk_set_event_handler(). dtk_process_events() returns if a  event  han‐
38       dler has returned 0 or if there is no more pending event in the queue.
39
40       If  dtk_set_event_handler() has never been called or called with handle
41       as NULL, it use a minimalistic event handler that returns 0 (i.e.  stop
42       the loop) when pressing the close button on the window.
43
44       The type ID of the event can be one of the following:
45
46       DTK_EVT_REDRAW
47              This  event  indicates that the whole window or parts of it must
48              be redrawn.  This may be caused by another window has been over‐
49              lapped  it  or  the window has been resized. If such an event is
50              received, the event pointer passed to the handler will be NULL.
51
52       DTK_EVT_QUIT
53              This event indicates that the close button  of  the  window  has
54              been clicked.  The event pointer passed will be NULL.
55
56       DTK_EVT_KEYBOARD
57              Indicates  that  a  key  of  the  keyboard  has  been pressed or
58              released. If such an event is received, the  meaningfull  member
59              of the union dtk_event will be key which is defined as follows:
60
61                  struct dtk_keyevent {
62                      unsigned int state;  /* pressed or released */
63                      unsigned int sym;    /* Symbolic code of the key */
64                      unsigned int mod;    /* modifiers key */
65                  };
66
67       DTK_EVT_MOUSEBUTTON
68              This  event  indicates  that  one  of the mouse buttons has been
69              pressed or released. If such an event is received, the  meaning‐
70              full  member  of  the  union  dtk_event  will  be mouse which is
71              defined as follows:
72
73                  struct dtk_mouseevent {
74                      unsigned int button; /* button identifier */
75                      unsigned int state;  /* pressed or realeased */
76                      unsigned int x;   /* x-coordinate of the mouse position */
77                      unsigned int y;   /* y-coordinate of the mouse position */
78                  };
79
80       DTK_EVT_MOUSEMOTION
81              This is similar to the DTK_EVT_MOUSEBUTTON  but  indicates  that
82              the  mouse has moved. Event data should also be accessed through
83              mouse member but its button and state members will  be  meaning‐
84              less.
85

RETURN VALUE

87       dtk_set_event_handler() does not return value.
88
89       dtk_process_events() returns 1 if there is no more pending event in the
90       queue.  It returns 0 if the processing loop has been interrupted by  an
91       event handler, i.e. the last event handler has returned 0.
92
93
94
95
96
97
98EPFL                                 2010                DTK_PROCESS_EVENTS(3)
Impressum