its about that time
[ardour2.git] / gtk2_ardour / evtest.cc
blobcdf9f028d419ae2fa5bd4e8d2242ab546468fb3f
1 #include <gtkmm.h>
2 #include <iostream>
4 using namespace std;
6 bool
7 print_event (GdkEvent* event)
9 cerr << hex;
10 cerr << "Event: type = " << event->type << ' ';
12 switch (event->type) {
13 case GDK_BUTTON_PRESS:
14 cerr << "Button press, button = "
15 << event->button.button
16 << " state "
17 << event->button.state
18 << endl;
19 break;
21 case GDK_BUTTON_RELEASE:
22 cerr << "Button release, button = "
23 << event->button.button
24 << " state "
25 << event->button.state
26 << endl;
27 break;
29 case GDK_SCROLL:
30 cerr << "Scroll: direction = "
31 << event->scroll.direction
32 << " state = "
33 << event->scroll.state
34 << endl;
35 break;
37 case GDK_KEY_PRESS:
38 cerr << "Key press, keycode = "
39 << event->key.keyval
40 << " name "
41 << gdk_keyval_name (event->key.keyval)
42 << " state = "
43 << event->key.state
44 << " hw keycode = "
45 << event->key.hardware_keycode
46 << " string = "
47 << (event->key.string ? event->key.string : "not defined")
48 << endl;
49 break;
51 case GDK_KEY_RELEASE:
52 cerr << "Key release, keycode = "
53 << event->key.keyval
54 << " name "
55 << gdk_keyval_name (event->key.keyval)
56 << " state = "
57 << event->key.state
58 << " hw keycode = "
59 << event->key.hardware_keycode
60 << " string = "
61 << (event->key.string ? event->key.string : "not defined")
62 << endl;
63 break;
65 default:
66 cerr << endl;
67 break;
69 cerr << dec;
71 return false;
74 int
75 main (int argc, char* argv[])
77 Gtk::Main app (&argc, &argv);
78 Gtk::Window window;
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);
88 eventbox.show ();
89 window.show ();
90 app.run();