diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-11-15 17:29:55 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2018-11-15 17:29:55 -0300 |
commit | 26d33d1c6eedf9271bac20a24ea37453c21ef890 (patch) | |
tree | f8d1ed5baa95f1f1e78d1952a2661b01546bbb32 | |
parent | 80a90ca824b3dd82ced0b047877949bb2f076a3e (diff) |
ViewportContainer was not passing unhandled input. Pass it, fixes #17326
-rw-r--r-- | scene/gui/viewport_container.cpp | 26 | ||||
-rw-r--r-- | scene/gui/viewport_container.h | 1 |
2 files changed, 27 insertions, 0 deletions
diff --git a/scene/gui/viewport_container.cpp b/scene/gui/viewport_container.cpp index 9d53c8876c..8e0d1cdd38 100644 --- a/scene/gui/viewport_container.cpp +++ b/scene/gui/viewport_container.cpp @@ -167,8 +167,34 @@ void ViewportContainer::_input(const Ref<InputEvent> &p_event) { } } +void ViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) { + + if (Engine::get_singleton()->is_editor_hint()) + return; + + Transform2D xform = get_global_transform(); + + if (stretch) { + Transform2D scale_xf; + scale_xf.scale(Vector2(shrink, shrink)); + xform *= scale_xf; + } + + Ref<InputEvent> ev = p_event->xformed_by(xform.affine_inverse()); + + for (int i = 0; i < get_child_count(); i++) { + + Viewport *c = Object::cast_to<Viewport>(get_child(i)); + if (!c || c->is_input_disabled()) + continue; + + c->unhandled_input(ev); + } +} + void ViewportContainer::_bind_methods() { + ClassDB::bind_method(D_METHOD("_unhandled_input", "event"), &ViewportContainer::_unhandled_input); ClassDB::bind_method(D_METHOD("_input", "event"), &ViewportContainer::_input); ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &ViewportContainer::set_stretch); ClassDB::bind_method(D_METHOD("is_stretch_enabled"), &ViewportContainer::is_stretch_enabled); diff --git a/scene/gui/viewport_container.h b/scene/gui/viewport_container.h index 45c4cd03a1..60aec25959 100644 --- a/scene/gui/viewport_container.h +++ b/scene/gui/viewport_container.h @@ -49,6 +49,7 @@ public: bool is_stretch_enabled() const; void _input(const Ref<InputEvent> &p_event); + void _unhandled_input(const Ref<InputEvent> &p_event); void set_stretch_shrink(int p_shrink); int get_stretch_shrink() const; |