properly pass events to parent controls, closes #4701

(cherry picked from commit aec5506414)
This commit is contained in:
Juan Linietsky 2016-06-06 22:03:29 -03:00 committed by Rémi Verschelde
parent bb8b57cbae
commit cb94271e9f
1 changed files with 23 additions and 15 deletions

View File

@ -1481,22 +1481,30 @@ void Viewport::_gui_call_input(Control *p_control,const InputEvent& p_input) {
// _block(); // _block();
while(p_control) { CanvasItem *ci=p_control;
while(ci) {
p_control->call_multilevel(SceneStringNames::get_singleton()->_input_event,p_input); Control *control = ci->cast_to<Control>();
if (gui.key_event_accepted) if (control) {
break; control->call_multilevel(SceneStringNames::get_singleton()->_input_event,p_input);
if (!p_control->is_inside_tree()) if (gui.key_event_accepted)
break; break;
p_control->emit_signal(SceneStringNames::get_singleton()->input_event,p_input); if (!control->is_inside_tree())
if (!p_control->is_inside_tree() || p_control->is_set_as_toplevel()) { break;
break; control->emit_signal(SceneStringNames::get_singleton()->input_event,p_input);
} if (!control->is_inside_tree() || control->is_set_as_toplevel()) {
if (gui.key_event_accepted) break;
break; }
if (p_control->data.stop_mouse && (p_input.type==InputEvent::MOUSE_BUTTON || p_input.type==InputEvent::MOUSE_MOTION)) if (gui.key_event_accepted)
break; break;
p_control=p_control->data.parent; 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(); //_unblock();