7 print_event (GdkEvent
* event
)
12 cerr
<< "Event: type = " << event
->type
<< ' ';
14 switch (event
->type
) {
15 case GDK_2BUTTON_PRESS
:
16 cerr
<< "2-Button press, button = "
17 << event
->button
.button
19 << event
->button
.state
23 case GDK_BUTTON_PRESS
:
24 cerr
<< "Button press, button = "
25 << event
->button
.button
27 << event
->button
.state
31 case GDK_BUTTON_RELEASE
:
32 cerr
<< "Button release, button = "
33 << event
->button
.button
35 << event
->button
.state
40 cerr
<< "Scroll: direction = "
41 << event
->scroll
.direction
43 << event
->scroll
.state
48 cerr
<< "Key press, keycode = "
51 << ((kstr
= gdk_keyval_name (event
->key
.keyval
)) ? kstr
: "UNKNOWN KEY")
55 << event
->key
.hardware_keycode
57 << (event
->key
.string
? event
->key
.string
: "not defined")
62 cerr
<< "Key release, keycode = "
65 << ((kstr
= gdk_keyval_name (event
->key
.keyval
)) ? kstr
: "UNKNOWN KEY")
69 << event
->key
.hardware_keycode
71 << (event
->key
.string
? event
->key
.string
: "not defined")
85 main (int argc
, char* argv
[])
87 Gtk::Main
app (&argc
, &argv
);
89 Gtk::EventBox eventbox
;
91 window
.add (eventbox
);
92 window
.set_size_request (250, 250);
94 eventbox
.signal_event().connect (sigc::ptr_fun (print_event
));
95 eventbox
.add_events (Gdk::SCROLL_MASK
|Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
);
96 eventbox
.set_flags (Gtk::CAN_FOCUS
);