Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <gtkmm.h>
- class MainWindow
- :
- public Gtk::Window
- {
- public:
- MainWindow();
- virtual ~MainWindow();
- private:
- bool get_key_info (GdkEventKey *);
- // Gtkmm Widgets...
- Gtk::Grid grid;
- Gtk::Entry entry;
- Gtk::Label label;
- };
- MainWindow::MainWindow()
- {
- set_title ("Window Keys");
- grid.set_column_homogeneous (false);
- grid.set_row_homogeneous (false);
- grid.set_row_spacing (10);
- grid.attach (entry, 0, 0, 1, 1);
- grid.attach (label, 0, 1, 1, 1);
- entry.signal_key_press_event().connect (
- sigc::mem_fun (*this, &MainWindow::get_key_info));
- add (grid);
- show_all_children();
- }
- bool
- MainWindow::get_key_info (GdkEventKey * key)
- {
- label.set_text (
- Glib::ustring::compose ("State : %1\n", key->state) +
- Glib::ustring::compose ("KeyVal : %1\n", key->keyval) +
- Glib::ustring::compose ("KeyCode : %1\n", key->hardware_keycode) +
- Glib::ustring::compose ("Group : %1\n", key->group) +
- Glib::ustring::compose ("Modifier? %1\n", key->is_modifier));
- return true;
- }
- MainWindow::~MainWindow()
- {
- }
- int main (int argc, char *argv[])
- {
- Glib::RefPtr<Gtk::Application> app =
- Gtk::Application::create (argc, argv);
- MainWindow main_window;
- return
- app->run (main_window);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement