Merge pull request #53630 from timothyqiu/viewport-recursion

This commit is contained in:
Rémi Verschelde 2021-10-11 10:02:22 +02:00 committed by GitHub
commit 56078cca90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2881,9 +2881,8 @@ bool Viewport::gui_is_dragging() const {
void Viewport::set_input_as_handled() { void Viewport::set_input_as_handled() {
_drop_physics_mouseover(); _drop_physics_mouseover();
if (handle_input_locally) {
local_input_handled = true; if (!handle_input_locally) {
} else {
ERR_FAIL_COND(!is_inside_tree()); ERR_FAIL_COND(!is_inside_tree());
Viewport *vp = this; Viewport *vp = this;
while (true) { while (true) {
@ -2895,16 +2894,19 @@ void Viewport::set_input_as_handled() {
} }
vp = vp->get_parent()->get_viewport(); vp = vp->get_parent()->get_viewport();
} }
if (vp != this) {
vp->set_input_as_handled(); vp->set_input_as_handled();
return;
} }
}
local_input_handled = true;
} }
bool Viewport::is_input_handled() const { bool Viewport::is_input_handled() const {
if (handle_input_locally) { if (!handle_input_locally) {
return local_input_handled;
} else {
const Viewport *vp = this;
ERR_FAIL_COND_V(!is_inside_tree(), false); ERR_FAIL_COND_V(!is_inside_tree(), false);
const Viewport *vp = this;
while (true) { while (true) {
if (Object::cast_to<Window>(vp)) { if (Object::cast_to<Window>(vp)) {
break; break;
@ -2914,8 +2916,11 @@ bool Viewport::is_input_handled() const {
} }
vp = vp->get_parent()->get_viewport(); vp = vp->get_parent()->get_viewport();
} }
if (vp != this) {
return vp->is_input_handled(); return vp->is_input_handled();
} }
}
return local_input_handled;
} }
void Viewport::set_handle_input_locally(bool p_enable) { void Viewport::set_handle_input_locally(bool p_enable) {