Merge pull request #77452 from Sauermann/fix-deprecate-push-unhandled-input
Deprecate push_unhandled_input
This commit is contained in:
commit
d998323ab4
4 changed files with 30 additions and 14 deletions
|
@ -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>
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue