7 print_event (GdkEvent
* event
)
10 cerr
<< "Event: type = " << event
->type
<< ' ';
12 switch (event
->type
) {
13 case GDK_BUTTON_PRESS
:
14 cerr
<< "Button press, button = "
15 << event
->button
.button
17 << event
->button
.state
21 case GDK_BUTTON_RELEASE
:
22 cerr
<< "Button release, button = "
23 << event
->button
.button
25 << event
->button
.state
30 cerr
<< "Scroll: direction = "
31 << event
->scroll
.direction
33 << event
->scroll
.state
38 cerr
<< "Key press, keycode = "
41 << gdk_keyval_name (event
->key
.keyval
)
45 << event
->key
.hardware_keycode
47 << (event
->key
.string
? event
->key
.string
: "not defined")
52 cerr
<< "Key release, keycode = "
55 << gdk_keyval_name (event
->key
.keyval
)
59 << event
->key
.hardware_keycode
61 << (event
->key
.string
? event
->key
.string
: "not defined")
75 main (int argc
, char* argv
[])
77 Gtk::Main
app (&argc
, &argv
);
79 Gtk::EventBox eventbox
;
81 window
.add (eventbox
);
82 window
.set_size_request (250, 250);
84 eventbox
.signal_event().connect (sigc::ptr_fun (print_event
));
85 eventbox
.add_events (Gdk::SCROLL_MASK
|Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
);
86 eventbox
.set_flags (Gtk::CAN_FOCUS
);