]> git.tdb.fi Git - libs/gui.git/commitdiff
Add focus events to the event test program
authorMikko Rasa <tdb@tdb.fi>
Mon, 19 Sep 2016 17:32:22 +0000 (20:32 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 19 Sep 2016 17:32:22 +0000 (20:32 +0300)
examples/ev.cpp

index 8029df2af8310a9c1e5a25a326b8d607bbfba085..cc15e71eb394005ac0a18c1a3acb44fa73187261 100644 (file)
@@ -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));