From: Mikko Rasa Date: Sun, 8 Sep 2019 15:32:19 +0000 (+0300) Subject: Add an event handler to allow containers to reach to focus changes X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=2b3940dd34611a6f669278de9a5146b6e85f6119;p=libs%2Fgltk.git Add an event handler to allow containers to reach to focus changes --- diff --git a/source/container.cpp b/source/container.cpp index a0d1fd7..2322733 100644 --- a/source/container.cpp +++ b/source/container.cpp @@ -151,12 +151,10 @@ void Container::set_input_focus(Widget *wdg) input_focus->focus_out(); input_focus = wdg; + on_input_focus_changed(input_focus); if(input_focus) - { - raise(*wdg); input_focus->focus_in(); - } } } @@ -356,6 +354,12 @@ void Container::on_reparent() } } +void Container::on_input_focus_changed(Widget *wdg) +{ + if(wdg) + raise(*wdg); +} + Container::Child::Child(Container &c, Widget *w): container(c), diff --git a/source/container.h b/source/container.h index f68d81f..3117236 100644 --- a/source/container.h +++ b/source/container.h @@ -92,6 +92,7 @@ protected: virtual void on_reparent(); virtual void on_child_added(Widget &) { } virtual void on_child_removed(Widget &) { } + virtual void on_input_focus_changed(Widget *); }; } // namespace GLtk