From 795340377eef0c9a612d602b28045762e900be77 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Tue, 27 Jun 2023 12:40:26 -0300 Subject: [PATCH] Allow `push_input()` to work when `gui_disable_input` is enabled on `Viewport`s --- doc/classes/Viewport.xml | 2 +- scene/2d/touch_screen_button.cpp | 2 +- scene/main/viewport.cpp | 6 +----- scene/main/window.cpp | 5 +++++ 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index e78404250798..845391da1d1f 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -262,7 +262,7 @@ The global canvas transform of the viewport. The canvas transform is relative to this. - If [code]true[/code], the viewport will not receive input events. + If [code]true[/code], the viewport will not receive input events. Inputs from [method push_input] will still be taken. If [code]true[/code], sub-windows (popups and dialogs) will be embedded inside application window as control-like nodes. If [code]false[/code], they will appear as separate windows handled by the operating system. diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp index 7da2fc3cb36e..a3e15408cd3a 100644 --- a/scene/2d/touch_screen_button.cpp +++ b/scene/2d/touch_screen_button.cpp @@ -315,7 +315,7 @@ void TouchScreenButton::_release(bool p_exiting_tree) { if (action != StringName()) { Input::get_singleton()->action_release(action); - if (!p_exiting_tree) { + if (!p_exiting_tree && !get_viewport()->is_input_disabled()) { Ref iea; iea.instantiate(); iea->set_action(action); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index e15a8e487025..e486ae79fb46 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2937,10 +2937,6 @@ void Viewport::push_input(const Ref &p_event, bool p_local_coords) { ERR_FAIL_COND(!is_inside_tree()); ERR_FAIL_COND(p_event.is_null()); - if (disable_input) { - return; - } - if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_ancestor_of(this)) { return; } @@ -2997,7 +2993,7 @@ void Viewport::push_unhandled_input(const Ref &p_event, bool p_local local_input_handled = false; - if (disable_input || !_can_consume_input_events()) { + if (!_can_consume_input_events()) { return; } diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 0aa6b69d6c77..3c7a6e536d6e 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -723,6 +723,11 @@ void Window::_event_callback(DisplayServer::WindowEvent p_event) { void Window::update_mouse_cursor_state() { ERR_MAIN_THREAD_GUARD; + + if (is_input_disabled()) { + return; + } + // Update states based on mouse cursor position. // This includes updated mouse_enter or mouse_exit signals or the current mouse cursor shape. // These details are set in Viewport::_gui_input_event. To instantly