Skip to content

Commit

Permalink
ViewportContainer was not passing unhandled input. Pass it, fixes #17326
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz committed Nov 15, 2018
1 parent 80a90ca commit 26d33d1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scene/gui/viewport_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions scene/gui/viewport_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ViewportContainer : public Container {
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;

Expand Down

0 comments on commit 26d33d1

Please sign in to comment.