]> git.tdb.fi Git - libs/gltk.git/commitdiff
Only focus widgets if the container is focused
authorMikko Rasa <tdb@tdb.fi>
Sun, 8 Sep 2019 15:28:21 +0000 (18:28 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 8 Sep 2019 15:28:21 +0000 (18:28 +0300)
This prevents issues where a widget could be focused before it's added
to a rooted hierarchy, presenting inconsistent focus state.

source/container.cpp
source/root.cpp

index 62e6e125429bb7a10ca10b33476bc5d36fbd1a92..a0d1fd748fc7abb3f353babe6a655a4345759515 100644 (file)
@@ -388,9 +388,10 @@ void Container::Child::visibility_changed(bool v)
 
 void Container::Child::request_focus()
 {
-       container.set_input_focus(widget);
        if(container.parent && container.visible)
                container.set_focus();
+       if(container.state&FOCUS)
+               container.set_input_focus(widget);
 }
 
 void Container::Child::grab_pointer()
index ad1ca5b7936cbef133056a0aa7296d7474055b6f..a76da5b84cc6abcbe49f5ae99ccf35e8e6d47774 100644 (file)
@@ -58,6 +58,9 @@ void Root::init(Graphics::Window *window)
        else
                shprog = 0;
 
+       if(keyboard)
+               set_state(FOCUS);
+
        update_style();
 
        if(mouse)