]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/root.cpp
Don't let input events that are passed to widgets go to other consumers
[libs/gltk.git] / source / root.cpp
index 89db305ea5bd291e7cfc9823c7a5a2964a837ec6..1dea150966a943b2093189fb4c90bc01f05334e8 100644 (file)
@@ -109,27 +109,41 @@ void Root::render() const
        Widget::render(renderer);
 }
 
-void Root::button_press_event(unsigned btn)
+bool Root::button_press_event(unsigned btn)
 {
        if(visible)
        {
+               Widget *old_focus = pointer_focus;
+
                int x, y;
                get_pointer(x, y);
                button_press(x, y, btn);
+
+               if(pointer_focus || old_focus)
+                       return true;
        }
+
+       return false;
 }
 
-void Root::button_release_event(unsigned btn)
+bool Root::button_release_event(unsigned btn)
 {
        if(visible)
        {
+               Widget *old_focus = pointer_focus;
+
                int x, y;
                get_pointer(x, y);
                button_release(x, y, btn);
+
+               if(pointer_focus || old_focus)
+                       return true;
        }
+
+       return false;
 }
 
-void Root::axis_motion_event(unsigned, float, float)
+bool Root::axis_motion_event(unsigned, float, float)
 {
        if(visible)
        {
@@ -149,26 +163,58 @@ void Root::axis_motion_event(unsigned, float, float)
                                lbl_tooltip->set_visible(false);
                        tooltip_target = 0;
                }
+
+               if(pointer_focus)
+                       return true;
        }
+
+       return false;
 }
 
-void Root::key_press_event(unsigned key)
+bool Root::key_press_event(unsigned key)
 {
        // XXX Modifiers
        if(visible)
+       {
+               Widget *old_focus = input_focus;
+
                key_press(key, 0);
+
+               if(input_focus || old_focus)
+                       return true;
+       }
+
+       return false;
 }
 
-void Root::key_release_event(unsigned key)
+bool Root::key_release_event(unsigned key)
 {
        if(visible)
+       {
+               Widget *old_focus = input_focus;
+
                key_release(key, 0);
+
+               if(input_focus || old_focus)
+                       return true;
+       }
+
+       return false;
 }
 
-void Root::character_event(StringCodec::unichar ch)
+bool Root::character_event(StringCodec::unichar ch)
 {
        if(visible)
+       {
+               Widget *old_focus = input_focus;
+
                character(ch);
+
+               if(input_focus || old_focus)
+                       return true;
+       }
+
+       return false;
 }
 
 void Root::get_pointer(int &x, int &y)