From 93d8f3cdd5f0166fcbf8456488e98bfd4d9e02bb Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 18 Jan 2019 17:53:36 -0300 Subject: [PATCH] respect mouse mode when setting enter/exit notifications and signals, fixes #19785 --- scene/main/viewport.cpp | 39 +++++++++++++++++++++++++++++++++++---- scene/main/viewport.h | 2 ++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 0633d194f7c..8df007dcc7c 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1533,6 +1533,35 @@ void Viewport::_gui_call_input(Control *p_control, const Ref &p_inpu //_unblock(); } +void Viewport::_gui_call_notification(Control *p_control, int p_what) { + + CanvasItem *ci = p_control; + while (ci) { + + Control *control = Object::cast_to(ci); + if (control) { + + if (control->data.mouse_filter != Control::MOUSE_FILTER_IGNORE) { + control->notification(p_what); + } + + if (!control->is_inside_tree()) + break; + + if (!control->is_inside_tree() || control->is_set_as_toplevel()) + break; + if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP) + break; + } + + if (ci->is_set_as_toplevel()) + break; + + ci = ci->get_parent_item(); + } + + //_unblock(); +} Control *Viewport::_gui_find_control(const Point2 &p_global) { _gui_prepare_subwindows(); @@ -1975,13 +2004,15 @@ void Viewport::_gui_input_event(Ref p_event) { if (over != gui.mouse_over) { - if (gui.mouse_over) - gui.mouse_over->notification(Control::NOTIFICATION_MOUSE_EXIT); + if (gui.mouse_over) { + _gui_call_notification(gui.mouse_over, Control::NOTIFICATION_MOUSE_EXIT); + } _gui_cancel_tooltip(); - if (over) - over->notification(Control::NOTIFICATION_MOUSE_ENTER); + if (over) { + _gui_call_notification(over, Control::NOTIFICATION_MOUSE_ENTER); + } } gui.mouse_over = over; diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 0565fd3d189..cdb9d4afb52 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -305,6 +305,8 @@ private: bool disable_input; void _gui_call_input(Control *p_control, const Ref &p_input); + void _gui_call_notification(Control *p_control, int p_what); + void _gui_prepare_subwindows(); void _gui_sort_subwindows(); void _gui_sort_roots();