diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index cad29f13bf6..f7df29fd191 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2496,6 +2496,9 @@ void Viewport::_gui_remove_control(Control *p_control) { gui.mouse_focus = NULL; gui.mouse_focus_mask = 0; } + if (gui.last_mouse_focus == p_control) { + gui.last_mouse_focus = NULL; + } if (gui.key_focus == p_control) gui.key_focus = NULL; if (gui.mouse_over == p_control)