From 065181a14ba9970c16a03110884bb36b3c82f786 Mon Sep 17 00:00:00 2001 From: Riteo Siuga Date: Fri, 19 Feb 2021 23:45:29 +0100 Subject: [PATCH] Focus all windows only on mouse clicks This makes OptionButtons usable again, as their window would otherwise get instantly focused by any input event, closing their popup. --- scene/main/window.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 8198fa41c505..ccefeb6a44a0 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -890,15 +890,18 @@ void Window::_window_input(const Ref &p_ev) { } if (exclusive_child != nullptr) { - Window *focus_target = exclusive_child; - focus_target->grab_focus(); - while (focus_target->exclusive_child != nullptr) { - focus_target = focus_target->exclusive_child; + Ref b = p_ev; + if (b.is_valid() && b->is_pressed() && b->get_button_index() == 0) { + Window *focus_target = exclusive_child; focus_target->grab_focus(); - } + while (focus_target->exclusive_child != nullptr) { + focus_target = focus_target->exclusive_child; + focus_target->grab_focus(); + } - if (!is_embedding_subwindows()) { //not embedding, no need for event - return; + if (!is_embedding_subwindows()) { //not embedding, no need for event + return; + } } }