diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 89e4128699c7..43158ac5d229 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2144,6 +2144,18 @@ void Viewport::_gui_input_event(Ref p_event) { over = _gui_find_control(mpos); } + if (over != gui.mouse_over) { + _drop_mouse_over(); + + _gui_cancel_tooltip(); + + if (over) { + _gui_call_notification(over, Control::NOTIFICATION_MOUSE_ENTER); + } + } + + gui.mouse_over = over; + if (gui.drag_data.get_type() == Variant::NIL && over && !gui.modal_stack.empty()) { Control *top = gui.modal_stack.back()->get(); @@ -2180,18 +2192,6 @@ void Viewport::_gui_input_event(Ref p_event) { } } - if (over != gui.mouse_over) { - _drop_mouse_over(); - - _gui_cancel_tooltip(); - - if (over) { - _gui_call_notification(over, Control::NOTIFICATION_MOUSE_ENTER); - } - } - - gui.mouse_over = over; - Control *drag_preview = _gui_get_drag_preview(); if (drag_preview) { drag_preview->set_position(mpos);