]> git.tdb.fi Git - libs/gltk.git/commitdiff
Only pass key and navigation events to enabled widgets
authorMikko Rasa <tdb@tdb.fi>
Fri, 2 Sep 2016 22:08:37 +0000 (01:08 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 2 Sep 2016 22:08:37 +0000 (01:08 +0300)
It would be even better to not allow them to be focused in the first
place, but that raises issues such as where to put the focus if the
focused widget gets disabled.  So this will have to do.

source/container.cpp

index c38509fd931fe37ca756818dbb575b5c3d20b210..91fa48758c8a60ec90cba48331798b3201906ae1 100644 (file)
@@ -274,7 +274,7 @@ void Container::touch_motion(int x, int y, unsigned finger)
 
 bool Container::key_press(unsigned key, unsigned mod)
 {
-       if(input_focus)
+       if(input_focus && input_focus->is_enabled())
                return input_focus->key_press(key, mod);
        else
                return false;
@@ -282,7 +282,7 @@ bool Container::key_press(unsigned key, unsigned mod)
 
 bool Container::key_release(unsigned key, unsigned mod)
 {
-       if(input_focus)
+       if(input_focus && input_focus->is_enabled())
                return input_focus->key_release(key, mod);
        else
                return false;
@@ -290,7 +290,7 @@ bool Container::key_release(unsigned key, unsigned mod)
 
 bool Container::character(wchar_t ch)
 {
-       if(input_focus)
+       if(input_focus && input_focus->is_enabled())
                return input_focus->character(ch);
        else
                return false;
@@ -304,7 +304,7 @@ void Container::focus_out()
 
 bool Container::navigate(Navigation nav)
 {
-       if(input_focus)
+       if(input_focus && input_focus->is_enabled())
                return input_focus->navigate(nav);
        else
                return false;