|
@@ -74,35 +74,35 @@ received input, in order:
|
|
2. Next if an embedded Window is focused, the event is sent to that Window and processed in
|
|
2. Next if an embedded Window is focused, the event is sent to that Window and processed in
|
|
the Windows Viewport and afterwards treated as handled. If no embedded Window is focused,
|
|
the Windows Viewport and afterwards treated as handled. If no embedded Window is focused,
|
|
the event is sent to the nodes of the current viewport in the following order.
|
|
the event is sent to the nodes of the current viewport in the following order.
|
|
-3. First of all, the standard :ref:`Node._input() <class_Node_method__input>` function
|
|
|
|
|
|
+3. First of all, the standard :ref:`Node._input() <class_Node_private_method__input>` function
|
|
will be called in any node that overrides it (and hasn't disabled input processing with :ref:`Node.set_process_input() <class_Node_method_set_process_input>`).
|
|
will be called in any node that overrides it (and hasn't disabled input processing with :ref:`Node.set_process_input() <class_Node_method_set_process_input>`).
|
|
If any function consumes the event, it can call :ref:`Viewport.set_input_as_handled() <class_Viewport_method_set_input_as_handled>`, and the event will
|
|
If any function consumes the event, it can call :ref:`Viewport.set_input_as_handled() <class_Viewport_method_set_input_as_handled>`, and the event will
|
|
not spread any more. This ensures that you can filter all events of interest, even before the GUI.
|
|
not spread any more. This ensures that you can filter all events of interest, even before the GUI.
|
|
- For gameplay input, :ref:`Node._unhandled_input() <class_Node_method__unhandled_input>` is generally a better fit, because it allows the GUI to intercept the events.
|
|
|
|
|
|
+ For gameplay input, :ref:`Node._unhandled_input() <class_Node_private_method__unhandled_input>` is generally a better fit, because it allows the GUI to intercept the events.
|
|
4. Second, it will try to feed the input to the GUI, and see if any
|
|
4. Second, it will try to feed the input to the GUI, and see if any
|
|
control can receive it. If so, the :ref:`Control <class_Control>` will be called via the
|
|
control can receive it. If so, the :ref:`Control <class_Control>` will be called via the
|
|
- virtual function :ref:`Control._gui_input() <class_Control_method__gui_input>` and the signal
|
|
|
|
|
|
+ virtual function :ref:`Control._gui_input() <class_Control_private_method__gui_input>` and the signal
|
|
"gui_input" will be emitted (this function is re-implementable by
|
|
"gui_input" will be emitted (this function is re-implementable by
|
|
script by inheriting from it). If the control wants to "consume" the
|
|
script by inheriting from it). If the control wants to "consume" the
|
|
event, it will call :ref:`Control.accept_event() <class_Control_method_accept_event>` and the event will
|
|
event, it will call :ref:`Control.accept_event() <class_Control_method_accept_event>` and the event will
|
|
not spread any more. Use the :ref:`Control.mouse_filter <class_Control_property_mouse_filter>`
|
|
not spread any more. Use the :ref:`Control.mouse_filter <class_Control_property_mouse_filter>`
|
|
property to control whether a :ref:`Control <class_Control>` is notified
|
|
property to control whether a :ref:`Control <class_Control>` is notified
|
|
- of mouse events via :ref:`Control._gui_input() <class_Control_method__gui_input>`
|
|
|
|
|
|
+ of mouse events via :ref:`Control._gui_input() <class_Control_private_method__gui_input>`
|
|
callback, and whether these events are propagated further.
|
|
callback, and whether these events are propagated further.
|
|
-5. If so far no one consumed the event, the :ref:`Node._shortcut_input() <class_Node_method__shortcut_input>` callback
|
|
|
|
|
|
+5. If so far no one consumed the event, the :ref:`Node._shortcut_input() <class_Node_private_method__shortcut_input>` callback
|
|
will be called if overridden (and not disabled with
|
|
will be called if overridden (and not disabled with
|
|
:ref:`Node.set_process_shortcut_input() <class_Node_method_set_process_shortcut_input>`).
|
|
:ref:`Node.set_process_shortcut_input() <class_Node_method_set_process_shortcut_input>`).
|
|
This happens only for :ref:`InputEventKey <class_InputEventKey>`,
|
|
This happens only for :ref:`InputEventKey <class_InputEventKey>`,
|
|
:ref:`InputEventShortcut <class_InputEventShortcut>` and :ref:`InputEventJoypadButton <class_InputEventJoypadButton>`.
|
|
:ref:`InputEventShortcut <class_InputEventShortcut>` and :ref:`InputEventJoypadButton <class_InputEventJoypadButton>`.
|
|
If any function consumes the event, it can call :ref:`Viewport.set_input_as_handled() <class_Viewport_method_set_input_as_handled>`, and the
|
|
If any function consumes the event, it can call :ref:`Viewport.set_input_as_handled() <class_Viewport_method_set_input_as_handled>`, and the
|
|
event will not spread any more. The shortcut input callback is ideal for treating events that are intended as shortcuts.
|
|
event will not spread any more. The shortcut input callback is ideal for treating events that are intended as shortcuts.
|
|
-6. If so far no one consumed the event, the :ref:`Node._unhandled_key_input() <class_Node_method__unhandled_key_input>` callback
|
|
|
|
|
|
+6. If so far no one consumed the event, the :ref:`Node._unhandled_key_input() <class_Node_private_method__unhandled_key_input>` callback
|
|
will be called if overridden (and not disabled with
|
|
will be called if overridden (and not disabled with
|
|
:ref:`Node.set_process_unhandled_key_input() <class_Node_method_set_process_unhandled_key_input>`).
|
|
:ref:`Node.set_process_unhandled_key_input() <class_Node_method_set_process_unhandled_key_input>`).
|
|
This happens only if the event is a :ref:`InputEventKey <class_InputEventKey>`.
|
|
This happens only if the event is a :ref:`InputEventKey <class_InputEventKey>`.
|
|
If any function consumes the event, it can call :ref:`Viewport.set_input_as_handled() <class_Viewport_method_set_input_as_handled>`, and the
|
|
If any function consumes the event, it can call :ref:`Viewport.set_input_as_handled() <class_Viewport_method_set_input_as_handled>`, and the
|
|
event will not spread any more. The unhandled key input callback is ideal for key events.
|
|
event will not spread any more. The unhandled key input callback is ideal for key events.
|
|
-7. If so far no one consumed the event, the :ref:`Node._unhandled_input() <class_Node_method__unhandled_input>` callback
|
|
|
|
|
|
+7. If so far no one consumed the event, the :ref:`Node._unhandled_input() <class_Node_private_method__unhandled_input>` callback
|
|
will be called if overridden (and not disabled with
|
|
will be called if overridden (and not disabled with
|
|
:ref:`Node.set_process_unhandled_input() <class_Node_method_set_process_unhandled_input>`).
|
|
:ref:`Node.set_process_unhandled_input() <class_Node_method_set_process_unhandled_input>`).
|
|
If any function consumes the event, it can call :ref:`Viewport.set_input_as_handled() <class_Viewport_method_set_input_as_handled>`, and the
|
|
If any function consumes the event, it can call :ref:`Viewport.set_input_as_handled() <class_Viewport_method_set_input_as_handled>`, and the
|
|
@@ -112,10 +112,10 @@ received input, in order:
|
|
enabled in :ref:`Project Settings <class_ProjectSettings_property_physics/common/enable_object_picking>`.
|
|
enabled in :ref:`Project Settings <class_ProjectSettings_property_physics/common/enable_object_picking>`.
|
|
In the case of a 3D scene if a :ref:`Camera3D <class_Camera3D>` is assigned to the Viewport, a ray
|
|
In the case of a 3D scene if a :ref:`Camera3D <class_Camera3D>` is assigned to the Viewport, a ray
|
|
to the physics world (in the ray direction from the click) will be cast. If this ray hits an object,
|
|
to the physics world (in the ray direction from the click) will be cast. If this ray hits an object,
|
|
- it will call the :ref:`CollisionObject3D._input_event() <class_CollisionObject3D_method__input_event>`
|
|
|
|
|
|
+ it will call the :ref:`CollisionObject3D._input_event() <class_CollisionObject3D_private_method__input_event>`
|
|
function in the relevant physics object (bodies receive this callback by default, but areas do
|
|
function in the relevant physics object (bodies receive this callback by default, but areas do
|
|
not. This can be configured through :ref:`Area3D <class_Area3D>` properties).
|
|
not. This can be configured through :ref:`Area3D <class_Area3D>` properties).
|
|
- In the case of a 2D scene, conceptually the same happens with :ref:`CollisionObject2D._input_event() <class_CollisionObject2D_method__input_event>`.
|
|
|
|
|
|
+ In the case of a 2D scene, conceptually the same happens with :ref:`CollisionObject2D._input_event() <class_CollisionObject2D_private_method__input_event>`.
|
|
|
|
|
|
When sending events to its child and descendant nodes, the viewport will do so, as depicted in
|
|
When sending events to its child and descendant nodes, the viewport will do so, as depicted in
|
|
the following graphic, in a reverse depth-first order, starting with the node at the bottom of
|
|
the following graphic, in a reverse depth-first order, starting with the node at the bottom of
|
|
@@ -124,7 +124,7 @@ and SubViewports.
|
|
|
|
|
|
.. image:: img/input_event_scene_flow.png
|
|
.. image:: img/input_event_scene_flow.png
|
|
|
|
|
|
-This order doesn't apply to :ref:`Control._gui_input() <class_Control_method__gui_input>`, which uses
|
|
|
|
|
|
+This order doesn't apply to :ref:`Control._gui_input() <class_Control_private_method__gui_input>`, which uses
|
|
a different method based on event location or focused Control.
|
|
a different method based on event location or focused Control.
|
|
|
|
|
|
Since Viewports don't send events to other :ref:`SubViewports <class_SubViewport>`, one of the following
|
|
Since Viewports don't send events to other :ref:`SubViewports <class_SubViewport>`, one of the following
|
|
@@ -132,7 +132,7 @@ methods has to be used:
|
|
|
|
|
|
1. Use a :ref:`SubViewportContainer <class_SubViewportContainer>`, which automatically
|
|
1. Use a :ref:`SubViewportContainer <class_SubViewportContainer>`, which automatically
|
|
sends events to its child :ref:`SubViewports <class_SubViewport>` after
|
|
sends events to its child :ref:`SubViewports <class_SubViewport>` after
|
|
- :ref:`Node._input() <class_Node_method__input>` or :ref:`Control._gui_input() <class_Control_method__gui_input>`.
|
|
|
|
|
|
+ :ref:`Node._input() <class_Node_private_method__input>` or :ref:`Control._gui_input() <class_Control_private_method__gui_input>`.
|
|
2. Implement event propagation based on the individual requirements.
|
|
2. Implement event propagation based on the individual requirements.
|
|
|
|
|
|
GUI events also travel up the scene tree but, since these events target
|
|
GUI events also travel up the scene tree but, since these events target
|