newgui: Capture key presses on the window

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2013-03-24 21:24:31 -04:00 committed by Anna Schumaker
parent 3c60dbdbae
commit 7dc88a1e46
2 changed files with 10 additions and 2 deletions

View File

@ -2,8 +2,6 @@
from config import *
env.ParseConfig('pkg-config --cflags --libs gtkmm-2.4')
#env.ParseConfig('pkg-config --cflags --libs gmodule-export-2.0')
#def script(target, source, env):
# f = open(str(target[0]), 'w')

View File

@ -1,7 +1,16 @@
// Copyright (c) 2013 Bryan Schumaker
#include <version.h>
#include <print.h>
#include "ocarina.h"
static bool key_pressed(GdkEventKey *event)
{
string key = gdk_keyval_name(event->keyval);
println("Key pressed: " + key);
return false;
}
void init_window()
{
Gtk::Window *window;
@ -9,4 +18,5 @@ void init_window()
window->set_title("Ocarina " + vers_str());
window->set_icon_from_file(lib_file("newgui.png"));
window->signal_key_press_event().connect(sigc::ptr_fun(&key_pressed));
}