]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/systemkeyboardinput.cpp
Don't pass events to an invisible root widget
[libs/gltk.git] / source / systemkeyboardinput.cpp
index fe803a6ddd2e407abbe1cdbcadaed5ec4ce989da..f5657bd7d49066d4c854279bfbfde8705ddbd55a 100644 (file)
@@ -16,6 +16,9 @@ SystemKeyboardInput::SystemKeyboardInput(Root &r, Input::Keyboard &k):
 
 bool SystemKeyboardInput::key_press(unsigned key)
 {
+       if(!root.is_visible())
+               return false;
+
        // TODO modifiers
        if(root.key_press(key, 0))
                return true;
@@ -37,12 +40,18 @@ bool SystemKeyboardInput::key_press(unsigned key)
 
 bool SystemKeyboardInput::key_release(unsigned key)
 {
-       return root.key_release(key, 0);
+       if(root.is_visible())
+               return root.key_release(key, 0);
+       else
+               return false;
 }
 
 bool SystemKeyboardInput::character(StringCodec::unichar ch)
 {
-       return root.character(ch);
+       if(root.is_visible())
+               return root.character(ch);
+       else
+               return false;
 }
 
 } // namespace GLtk