From aec550641429ace3ff7b3db57c3fb33d8f1def4c Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 6 Jun 2016 22:03:29 -0300 Subject: [PATCH] properly pass events to parent controls, closes #4701 --- scene/main/viewport.cpp | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 313be88526b..d3f0a6e2e08 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1492,22 +1492,30 @@ void Viewport::_gui_call_input(Control *p_control,const InputEvent& p_input) { // _block(); - while(p_control) { + CanvasItem *ci=p_control; + while(ci) { - p_control->call_multilevel(SceneStringNames::get_singleton()->_input_event,p_input); - if (gui.key_event_accepted) - break; - if (!p_control->is_inside_tree()) - break; - p_control->emit_signal(SceneStringNames::get_singleton()->input_event,p_input); - if (!p_control->is_inside_tree() || p_control->is_set_as_toplevel()) { - break; - } - if (gui.key_event_accepted) - break; - if (p_control->data.stop_mouse && (p_input.type==InputEvent::MOUSE_BUTTON || p_input.type==InputEvent::MOUSE_MOTION)) - break; - p_control=p_control->data.parent; + Control *control = ci->cast_to(); + if (control) { + control->call_multilevel(SceneStringNames::get_singleton()->_input_event,p_input); + if (gui.key_event_accepted) + break; + if (!control->is_inside_tree()) + break; + control->emit_signal(SceneStringNames::get_singleton()->input_event,p_input); + if (!control->is_inside_tree() || control->is_set_as_toplevel()) { + break; + } + if (gui.key_event_accepted) + break; + if (control->data.stop_mouse && (p_input.type==InputEvent::MOUSE_BUTTON || p_input.type==InputEvent::MOUSE_MOTION)) + break; + } + + if (ci->is_set_as_toplevel()) + break; + + ci=ci->get_parent_item(); } //_unblock();