summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/classes/InputEventShortcut.xml2
-rw-r--r--doc/classes/Viewport.xml4
-rw-r--r--scene/main/viewport.cpp34
-rw-r--r--scene/main/viewport.h4
4 files changed, 30 insertions, 14 deletions
diff --git a/doc/classes/InputEventShortcut.xml b/doc/classes/InputEventShortcut.xml
index 120c9d8703..4141888d2c 100644
--- a/doc/classes/InputEventShortcut.xml
+++ b/doc/classes/InputEventShortcut.xml
@@ -4,7 +4,7 @@
Represents a triggered keyboard [Shortcut].
</brief_description>
<description>
- InputEventShortcut is a special event that can be received in [method Node._unhandled_key_input]. It is typically sent by the editor's Command Palette to trigger actions, but can also be sent manually using [method Viewport.push_unhandled_input].
+ InputEventShortcut is a special event that can be received in [method Node._unhandled_key_input]. It is typically sent by the editor's Command Palette to trigger actions, but can also be sent manually using [method Viewport.push_input].
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml
index 20a1424f41..d363a11550 100644
--- a/doc/classes/Viewport.xml
+++ b/doc/classes/Viewport.xml
@@ -173,7 +173,7 @@
Helper method which calls the [code]set_text()[/code] method on the currently focused [Control], provided that it is defined (e.g. if the focused Control is [Button] or [LineEdit]).
</description>
</method>
- <method name="push_unhandled_input">
+ <method name="push_unhandled_input" is_deprecated="true">
<return type="void" />
<param index="0" name="event" type="InputEvent" />
<param index="1" name="in_local_coords" type="bool" default="false" />
@@ -187,6 +187,8 @@
- [method Node._unhandled_key_input]
If an earlier method marks the input as handled via [method set_input_as_handled], any later method in this list will not be called.
If none of the methods handle the event and [member physics_object_picking] is [code]true[/code], the event is used for physics object picking.
+ [b]Note:[/b] This method doesn't propagate input events to embedded [Window]s or [SubViewport]s.
+ [b]Note:[/b] This method is deprecated, use [method push_input] instead.
</description>
</method>
<method name="set_canvas_cull_mask_bit">
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index e6ebaba79e..e7970b212e 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2999,16 +2999,19 @@ void Viewport::push_input(const Ref<InputEvent> &p_event, bool p_local_coords) {
}
if (!is_input_handled()) {
- push_unhandled_input(ev, true);
+ _push_unhandled_input_internal(ev);
}
event_count++;
}
+#ifndef DISABLE_DEPRECATED
void Viewport::push_unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coords) {
ERR_MAIN_THREAD_GUARD;
ERR_FAIL_COND(p_event.is_null());
ERR_FAIL_COND(!is_inside_tree());
+ WARN_DEPRECATED_MSG(R"(The "push_unhandled_input" method is deprecated, use "push_input" instead.)");
+
local_input_handled = false;
if (disable_input || !_can_consume_input_events()) {
@@ -3026,31 +3029,36 @@ void Viewport::push_unhandled_input(const Ref<InputEvent> &p_event, bool p_local
ev = p_event;
}
+ _push_unhandled_input_internal(ev);
+}
+#endif // DISABLE_DEPRECATED
+
+void Viewport::_push_unhandled_input_internal(const Ref<InputEvent> &p_event) {
// Shortcut Input.
- if (Object::cast_to<InputEventKey>(*ev) != nullptr || Object::cast_to<InputEventShortcut>(*ev) != nullptr || Object::cast_to<InputEventJoypadButton>(*ev) != nullptr) {
- get_tree()->_call_input_pause(shortcut_input_group, SceneTree::CALL_INPUT_TYPE_SHORTCUT_INPUT, ev, this);
+ if (Object::cast_to<InputEventKey>(*p_event) != nullptr || Object::cast_to<InputEventShortcut>(*p_event) != nullptr || Object::cast_to<InputEventJoypadButton>(*p_event) != nullptr) {
+ get_tree()->_call_input_pause(shortcut_input_group, SceneTree::CALL_INPUT_TYPE_SHORTCUT_INPUT, p_event, this);
}
// Unhandled Input.
if (!is_input_handled()) {
- get_tree()->_call_input_pause(unhandled_input_group, SceneTree::CALL_INPUT_TYPE_UNHANDLED_INPUT, ev, this);
+ get_tree()->_call_input_pause(unhandled_input_group, SceneTree::CALL_INPUT_TYPE_UNHANDLED_INPUT, p_event, this);
}
// Unhandled key Input - Used for performance reasons - This is called a lot less than _unhandled_input since it ignores MouseMotion, and to handle Unicode input with Alt / Ctrl modifiers after handling shortcuts.
- if (!is_input_handled() && (Object::cast_to<InputEventKey>(*ev) != nullptr)) {
- get_tree()->_call_input_pause(unhandled_key_input_group, SceneTree::CALL_INPUT_TYPE_UNHANDLED_KEY_INPUT, ev, this);
+ if (!is_input_handled() && (Object::cast_to<InputEventKey>(*p_event) != nullptr)) {
+ get_tree()->_call_input_pause(unhandled_key_input_group, SceneTree::CALL_INPUT_TYPE_UNHANDLED_KEY_INPUT, p_event, this);
}
if (physics_object_picking && !is_input_handled()) {
if (Input::get_singleton()->get_mouse_mode() != Input::MOUSE_MODE_CAPTURED &&
- (Object::cast_to<InputEventMouseButton>(*ev) ||
- Object::cast_to<InputEventMouseMotion>(*ev) ||
- Object::cast_to<InputEventScreenDrag>(*ev) ||
- Object::cast_to<InputEventScreenTouch>(*ev) ||
- Object::cast_to<InputEventKey>(*ev) // To remember state.
+ (Object::cast_to<InputEventMouseButton>(*p_event) ||
+ Object::cast_to<InputEventMouseMotion>(*p_event) ||
+ Object::cast_to<InputEventScreenDrag>(*p_event) ||
+ Object::cast_to<InputEventScreenTouch>(*p_event) ||
+ Object::cast_to<InputEventKey>(*p_event) // To remember state.
)) {
- physics_picking_events.push_back(ev);
+ physics_picking_events.push_back(p_event);
set_input_as_handled();
}
}
@@ -4144,7 +4152,9 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_viewport_rid"), &Viewport::get_viewport_rid);
ClassDB::bind_method(D_METHOD("push_text_input", "text"), &Viewport::push_text_input);
ClassDB::bind_method(D_METHOD("push_input", "event", "in_local_coords"), &Viewport::push_input, DEFVAL(false));
+#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("push_unhandled_input", "event", "in_local_coords"), &Viewport::push_unhandled_input, DEFVAL(false));
+#endif // DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("get_camera_2d"), &Viewport::get_camera_2d);
ClassDB::bind_method(D_METHOD("set_as_audio_listener_2d", "enable"), &Viewport::set_as_audio_listener_2d);
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 8870ed6eca..63cddddbcb 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -414,6 +414,8 @@ private:
void _perform_drop(Control *p_control = nullptr, Point2 p_pos = Point2());
void _gui_cleanup_internal_state(Ref<InputEvent> p_event);
+ void _push_unhandled_input_internal(const Ref<InputEvent> &p_event);
+
Ref<InputEvent> _make_input_local(const Ref<InputEvent> &ev);
friend class Control;
@@ -575,7 +577,9 @@ public:
void push_text_input(const String &p_text);
void push_input(const Ref<InputEvent> &p_event, bool p_local_coords = false);
+#ifndef DISABLE_DEPRECATED
void push_unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coords = false);
+#endif // DISABLE_DEPRECATED
void set_disable_input(bool p_disable);
bool is_input_disabled() const;