From: Mikko Rasa Date: Tue, 30 Aug 2011 18:27:46 +0000 (+0300) Subject: Output character events in the event example X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=4c19b0b1fef474cc098287d4ba32555bc4dfa3b9;p=libs%2Fgui.git Output character events in the event example --- diff --git a/examples/ev.cpp b/examples/ev.cpp index 9ded9c7..5a338e7 100644 --- a/examples/ev.cpp +++ b/examples/ev.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include using namespace Msp; @@ -21,6 +23,7 @@ private: void key_press(unsigned); void key_release(unsigned); + void character(StringCodec::unichar); void button_press(unsigned); void button_release(unsigned); void axis_motion(unsigned, float, float); @@ -34,6 +37,7 @@ Ev::Ev(int, char **): window.signal_close.connect(sigc::bind(sigc::mem_fun(this, &Ev::exit), 0)); keyboard.signal_button_press.connect(sigc::mem_fun(this, &Ev::key_press)); keyboard.signal_button_release.connect(sigc::mem_fun(this, &Ev::key_release)); + keyboard.signal_character.connect(sigc::mem_fun(this, &Ev::character)); mouse.signal_button_press.connect(sigc::mem_fun(this, &Ev::button_press)); mouse.signal_button_release.connect(sigc::mem_fun(this, &Ev::button_release)); mouse.signal_axis_motion.connect(sigc::mem_fun(this, &Ev::axis_motion)); @@ -55,6 +59,11 @@ void Ev::key_release(unsigned key) IO::print("key_release: %s\n", keyboard.get_button_name(key)); } +void Ev::character(StringCodec::unichar ch) +{ + IO::print("character: %s\n", StringCodec::encode(StringCodec::ustring(1, ch))); +} + void Ev::button_press(unsigned btn) { IO::print("button_press: %s\n", mouse.get_button_name(btn));