From 2b3940dd34611a6f669278de9a5146b6e85f6119 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 8 Sep 2019 18:32:19 +0300 Subject: [PATCH] Add an event handler to allow containers to reach to focus changes --- source/container.cpp | 10 +++++++--- source/container.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) 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 -- 2.45.2