Mercurial > MadButterfly
comparison nodejs/observer.cc @ 679:799c852b9065
Extract event info from C object to JS object
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Fri, 06 Aug 2010 19:31:37 +0800 |
parents | f264b50c469c |
children | ddce24029561 |
comparison
equal
deleted
inserted
replaced
678:40ba8915edc7 | 679:799c852b9065 |
---|---|
16 Persistent<Function> func; | 16 Persistent<Function> func; |
17 }; | 17 }; |
18 | 18 |
19 static void | 19 static void |
20 event_handler(event_t *evt, void *arg); | 20 event_handler(event_t *evt, void *arg); |
21 | |
22 static void | |
23 xnjsmb_event_mod(Handle<Object> self, event_t *evt) { | |
24 mouse_event_t *mevt; | |
25 X_kb_event_t *xkbevt; | |
26 | |
27 switch(evt->type) { | |
28 case EVT_ANY: | |
29 case EVT_MOUSE_OVER: | |
30 case EVT_MOUSE_OUT: | |
31 case EVT_MOUSE_MOVE: | |
32 case EVT_MOUSE_BUT_PRESS: | |
33 case EVT_MOUSE_BUT_RELEASE: | |
34 mevt = (mouse_event_t *)evt; | |
35 SET(self, "x", Integer::New(mevt->x)); | |
36 SET(self, "y", Integer::New(mevt->y)); | |
37 SET(self, "but_state", Integer::New(mevt->but_state)); | |
38 SET(self, "button", Integer::New(mevt->button)); | |
39 break; | |
40 | |
41 case EVT_KB_PRESS: | |
42 case EVT_KB_RELEASE: | |
43 xkbevt = (X_kb_event_t *)evt; | |
44 SET(self, "keycode", Integer::New(xkbevt->keycode)); | |
45 SET(self, "sym", Integer::New(xkbevt->sym)); | |
46 break; | |
47 | |
48 case EVT_PROGM_COMPLETE: | |
49 case EVT_RDMAN_REDRAW: | |
50 case EVT_MONITOR_ADD: | |
51 case EVT_MONITOR_REMOVE: | |
52 case EVT_MONITOR_FREE: | |
53 case EVT_MOUSE_MOVE_RAW: | |
54 default: | |
55 /* Not implemented. Do nothing. */ | |
56 break; | |
57 } | |
58 } | |
21 | 59 |
22 static observer_t * | 60 static observer_t * |
23 _subject_add_event_observer(subject_t *subject, int type, | 61 _subject_add_event_observer(subject_t *subject, int type, |
24 Handle<Function> func) { | 62 Handle<Function> func) { |
25 observer_t *observer; | 63 observer_t *observer; |