123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- :github_url: hide
- .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
- .. DO NOT EDIT THIS FILE, but the Signal.xml source instead.
- .. The source is found in doc/classes or modules/<name>/doc_classes.
- .. _class_Signal:
- Signal
- ======
- Class representing a signal defined in an object.
- Constructors
- ------------
- +-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Signal<class_Signal>` | :ref:`Signal<class_Signal_constructor_Signal>` **(** **)** |
- +-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Signal<class_Signal>` | :ref:`Signal<class_Signal_constructor_Signal>` **(** :ref:`Signal<class_Signal>` from **)** |
- +-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Signal<class_Signal>` | :ref:`Signal<class_Signal_constructor_Signal>` **(** :ref:`Object<class_Object>` object, :ref:`StringName<class_StringName>` signal **)** |
- +-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
- Methods
- -------
- +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`connect<class_Signal_method_connect>` **(** :ref:`Callable<class_Callable>` callable, :ref:`int<class_int>` flags=0 **)** |
- +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`disconnect<class_Signal_method_disconnect>` **(** :ref:`Callable<class_Callable>` callable **)** |
- +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`emit<class_Signal_method_emit>` **(** ... **)** |vararg| |const| |
- +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Array<class_Array>` | :ref:`get_connections<class_Signal_method_get_connections>` **(** **)** |const| |
- +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`StringName<class_StringName>` | :ref:`get_name<class_Signal_method_get_name>` **(** **)** |const| |
- +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Object<class_Object>` | :ref:`get_object<class_Signal_method_get_object>` **(** **)** |const| |
- +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_object_id<class_Signal_method_get_object_id>` **(** **)** |const| |
- +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_connected<class_Signal_method_is_connected>` **(** :ref:`Callable<class_Callable>` callable **)** |const| |
- +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_null<class_Signal_method_is_null>` **(** **)** |const| |
- +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- Operators
- ---------
- +-------------------------+--------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`operator !=<class_Signal_operator_neq_bool>` **(** **)** |
- +-------------------------+--------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`operator !=<class_Signal_operator_neq_bool>` **(** :ref:`Signal<class_Signal>` right **)** |
- +-------------------------+--------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`operator ==<class_Signal_operator_eq_bool>` **(** **)** |
- +-------------------------+--------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`operator ==<class_Signal_operator_eq_bool>` **(** :ref:`Signal<class_Signal>` right **)** |
- +-------------------------+--------------------------------------------------------------------------------------------------+
- Constructor Descriptions
- ------------------------
- .. _class_Signal_constructor_Signal:
- - :ref:`Signal<class_Signal>` **Signal** **(** **)**
- Constructs a null ``Signal`` with no object nor signal name bound.
- ----
- - :ref:`Signal<class_Signal>` **Signal** **(** :ref:`Signal<class_Signal>` from **)**
- Constructs a ``Signal`` as a copy of the given ``Signal``.
- ----
- - :ref:`Signal<class_Signal>` **Signal** **(** :ref:`Object<class_Object>` object, :ref:`StringName<class_StringName>` signal **)**
- Creates a new ``Signal`` with the name ``signal`` in the specified ``object``.
- Method Descriptions
- -------------------
- .. _class_Signal_method_connect:
- - :ref:`int<class_int>` **connect** **(** :ref:`Callable<class_Callable>` callable, :ref:`int<class_int>` flags=0 **)**
- Connects this signal to the specified :ref:`Callable<class_Callable>`, optionally providing connection flags. You can provide additional arguments to the connected method call by using :ref:`Callable.bind<class_Callable_method_bind>`.
- ::
- for button in $Buttons.get_children():
- button.pressed.connect(on_pressed.bind(button))
-
- func on_pressed(button):
- print(button.name, " was pressed")
- ----
- .. _class_Signal_method_disconnect:
- - void **disconnect** **(** :ref:`Callable<class_Callable>` callable **)**
- Disconnects this signal from the specified :ref:`Callable<class_Callable>`.
- ----
- .. _class_Signal_method_emit:
- - void **emit** **(** ... **)** |vararg| |const|
- Emits this signal to all connected objects.
- ----
- .. _class_Signal_method_get_connections:
- - :ref:`Array<class_Array>` **get_connections** **(** **)** |const|
- Returns the list of :ref:`Callable<class_Callable>`\ s connected to this signal.
- ----
- .. _class_Signal_method_get_name:
- - :ref:`StringName<class_StringName>` **get_name** **(** **)** |const|
- Returns the name of this signal.
- ----
- .. _class_Signal_method_get_object:
- - :ref:`Object<class_Object>` **get_object** **(** **)** |const|
- Returns the object emitting this signal.
- ----
- .. _class_Signal_method_get_object_id:
- - :ref:`int<class_int>` **get_object_id** **(** **)** |const|
- Returns the ID of the object emitting this signal (see :ref:`Object.get_instance_id<class_Object_method_get_instance_id>`).
- ----
- .. _class_Signal_method_is_connected:
- - :ref:`bool<class_bool>` **is_connected** **(** :ref:`Callable<class_Callable>` callable **)** |const|
- Returns ``true`` if the specified :ref:`Callable<class_Callable>` is connected to this signal.
- ----
- .. _class_Signal_method_is_null:
- - :ref:`bool<class_bool>` **is_null** **(** **)** |const|
- Operator Descriptions
- ---------------------
- .. _class_Signal_operator_neq_bool:
- - :ref:`bool<class_bool>` **operator !=** **(** **)**
- ----
- - :ref:`bool<class_bool>` **operator !=** **(** :ref:`Signal<class_Signal>` right **)**
- ----
- .. _class_Signal_operator_eq_bool:
- - :ref:`bool<class_bool>` **operator ==** **(** **)**
- ----
- - :ref:`bool<class_bool>` **operator ==** **(** :ref:`Signal<class_Signal>` right **)**
- .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
- .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
- .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
- .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
- .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
- .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
|