summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-10-11 10:02:22 +0200
committerGitHub <noreply@github.com>2021-10-11 10:02:22 +0200
commit56078cca90402c2ea49252216b96f53fc649d4ec (patch)
treeb5593e3e76e04c9c8623537d6a6066bfdde73e1a /scene
parent8bd6b95ac44efc9a72aa0835f6a30537894e2b06 (diff)
parent7ecb133b224b6d96e60d7eb9c080ec6f23130d8d (diff)
Merge pull request #53630 from timothyqiu/viewport-recursion
Diffstat (limited to 'scene')
-rw-r--r--scene/main/viewport.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 2982e33fcf..0e62e6e30a 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2881,9 +2881,8 @@ bool Viewport::gui_is_dragging() const {
void Viewport::set_input_as_handled() {
_drop_physics_mouseover();
- if (handle_input_locally) {
- local_input_handled = true;
- } else {
+
+ if (!handle_input_locally) {
ERR_FAIL_COND(!is_inside_tree());
Viewport *vp = this;
while (true) {
@@ -2895,16 +2894,19 @@ void Viewport::set_input_as_handled() {
}
vp = vp->get_parent()->get_viewport();
}
- vp->set_input_as_handled();
+ if (vp != this) {
+ vp->set_input_as_handled();
+ return;
+ }
}
+
+ local_input_handled = true;
}
bool Viewport::is_input_handled() const {
- if (handle_input_locally) {
- return local_input_handled;
- } else {
- const Viewport *vp = this;
+ if (!handle_input_locally) {
ERR_FAIL_COND_V(!is_inside_tree(), false);
+ const Viewport *vp = this;
while (true) {
if (Object::cast_to<Window>(vp)) {
break;
@@ -2914,8 +2916,11 @@ bool Viewport::is_input_handled() const {
}
vp = vp->get_parent()->get_viewport();
}
- return vp->is_input_handled();
+ if (vp != this) {
+ return vp->is_input_handled();
+ }
}
+ return local_input_handled;
}
void Viewport::set_handle_input_locally(bool p_enable) {