]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/container.cpp
Clear saved input focus if the widget is removed from the container
[libs/gltk.git] / source / container.cpp
index 393973cc2ab7293adcd32c3e939442780e0ff23e..9ef46f1ab85fcd511238ecb83f3f45cf912b7caa 100644 (file)
@@ -35,6 +35,8 @@ void Container::remove(Widget &wdg)
        if(i==children.end())
                throw hierarchy_error("widget not in container");
 
+       if(&wdg==saved_input_focus)
+               saved_input_focus = nullptr;
        wdg.set_parent(nullptr);
        delete *i;
        children.erase(i);
@@ -317,7 +319,7 @@ bool Container::character(wchar_t ch)
 
 void Container::focus_in()
 {
-       if(saved_input_focus && saved_input_focus->get_parent()==this)
+       if(saved_input_focus)
                set_input_focus(saved_input_focus);
        Widget::focus_in();
 }