diff --git a/doc/classes/SubViewportContainer.xml b/doc/classes/SubViewportContainer.xml
index 08e7ca23f74a..e7d7883c786f 100644
--- a/doc/classes/SubViewportContainer.xml
+++ b/doc/classes/SubViewportContainer.xml
@@ -10,6 +10,15 @@
+
+
+
+
+
+ Virtual method to be implemented by the user. If it returns [code]true[/code], the [param event] is propagated to [SubViewport] children. Propagation doesn't happen if it returns [code]false[/code]. If the function is not implemented, all events are propagated to SubViewports.
+
+
+
diff --git a/scene/gui/subviewport_container.cpp b/scene/gui/subviewport_container.cpp
index 851a94b32f2f..0d33774e2087 100644
--- a/scene/gui/subviewport_container.cpp
+++ b/scene/gui/subviewport_container.cpp
@@ -190,6 +190,13 @@ void SubViewportContainer::_propagate_nonpositional_event(const Ref
return;
}
+ bool send;
+ if (GDVIRTUAL_CALL(_propagate_input_event, p_event, send)) {
+ if (!send) {
+ return;
+ }
+ }
+
_send_event_to_viewports(p_event);
}
@@ -204,6 +211,13 @@ void SubViewportContainer::gui_input(const Ref &p_event) {
return;
}
+ bool send;
+ if (GDVIRTUAL_CALL(_propagate_input_event, p_event, send)) {
+ if (!send) {
+ return;
+ }
+ }
+
if (stretch && shrink > 1) {
Transform2D xform;
xform.scale(Vector2(1, 1) / shrink);
@@ -275,6 +289,8 @@ void SubViewportContainer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stretch"), "set_stretch", "is_stretch_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "stretch_shrink"), "set_stretch_shrink", "get_stretch_shrink");
+
+ GDVIRTUAL_BIND(_propagate_input_event, "event");
}
SubViewportContainer::SubViewportContainer() {
diff --git a/scene/gui/subviewport_container.h b/scene/gui/subviewport_container.h
index 3c6cd09d6660..06420de7303b 100644
--- a/scene/gui/subviewport_container.h
+++ b/scene/gui/subviewport_container.h
@@ -50,6 +50,8 @@ class SubViewportContainer : public Container {
virtual void add_child_notify(Node *p_child) override;
virtual void remove_child_notify(Node *p_child) override;
+ GDVIRTUAL1RC(bool, _propagate_input_event, Ref);
+
public:
void set_stretch(bool p_enable);
bool is_stretch_enabled() const;