From: Mikko Rasa Date: Mon, 19 Sep 2016 17:32:22 +0000 (+0300) Subject: Add focus events to the event test program X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=971d9f711244232c991d77e09b2d801eba8e6d1a;p=libs%2Fgui.git Add focus events to the event test program --- diff --git a/examples/ev.cpp b/examples/ev.cpp index 8029df2..cc15e71 100644 --- a/examples/ev.cpp +++ b/examples/ev.cpp @@ -23,6 +23,8 @@ public: private: virtual void tick(); + void got_focus(); + void lost_focus(); void key_press(unsigned); void key_release(unsigned); void character(StringCodec::unichar); @@ -36,6 +38,8 @@ Ev::Ev(int, char **): keyboard(window), mouse(window) { + window.get_display().signal_got_focus.connect(sigc::mem_fun(this, &Ev::got_focus)); + window.get_display().signal_lost_focus.connect(sigc::mem_fun(this, &Ev::lost_focus)); window.signal_close.connect(sigc::bind(sigc::mem_fun(this, &Ev::exit), 0)); keyboard.signal_button_press.connect(sigc::bind_return(sigc::mem_fun(this, &Ev::key_press), false)); keyboard.signal_button_release.connect(sigc::bind_return(sigc::mem_fun(this, &Ev::key_release), false)); @@ -53,6 +57,16 @@ void Ev::tick() Time::sleep(Time::msec); } +void Ev::got_focus() +{ + IO::print("got_focus\n"); +} + +void Ev::lost_focus() +{ + IO::print("lost_focus\n"); +} + void Ev::key_press(unsigned key) { IO::print("key_press: %s\n", keyboard.get_button_name(key));