class_signal.rst 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Signal.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Signal:
  6. Signal
  7. ======
  8. Class representing a signal defined in an object.
  9. Constructors
  10. ------------
  11. +-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  12. | :ref:`Signal<class_Signal>` | :ref:`Signal<class_Signal_constructor_Signal>` **(** **)** |
  13. +-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  14. | :ref:`Signal<class_Signal>` | :ref:`Signal<class_Signal_constructor_Signal>` **(** :ref:`Signal<class_Signal>` from **)** |
  15. +-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`Signal<class_Signal>` | :ref:`Signal<class_Signal_constructor_Signal>` **(** :ref:`Object<class_Object>` object, :ref:`StringName<class_StringName>` signal **)** |
  17. +-----------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  18. Methods
  19. -------
  20. +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`int<class_int>` | :ref:`connect<class_Signal_method_connect>` **(** :ref:`Callable<class_Callable>` callable, :ref:`int<class_int>` flags=0 **)** |
  22. +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`disconnect<class_Signal_method_disconnect>` **(** :ref:`Callable<class_Callable>` callable **)** |
  24. +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`emit<class_Signal_method_emit>` **(** ... **)** |vararg| |const| |
  26. +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Array<class_Array>` | :ref:`get_connections<class_Signal_method_get_connections>` **(** **)** |const| |
  28. +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`StringName<class_StringName>` | :ref:`get_name<class_Signal_method_get_name>` **(** **)** |const| |
  30. +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`Object<class_Object>` | :ref:`get_object<class_Signal_method_get_object>` **(** **)** |const| |
  32. +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`int<class_int>` | :ref:`get_object_id<class_Signal_method_get_object_id>` **(** **)** |const| |
  34. +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`is_connected<class_Signal_method_is_connected>` **(** :ref:`Callable<class_Callable>` callable **)** |const| |
  36. +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`bool<class_bool>` | :ref:`is_null<class_Signal_method_is_null>` **(** **)** |const| |
  38. +-------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  39. Operators
  40. ---------
  41. +-------------------------+--------------------------------------------------------------------------------------------------+
  42. | :ref:`bool<class_bool>` | :ref:`operator !=<class_Signal_operator_neq_bool>` **(** **)** |
  43. +-------------------------+--------------------------------------------------------------------------------------------------+
  44. | :ref:`bool<class_bool>` | :ref:`operator !=<class_Signal_operator_neq_bool>` **(** :ref:`Signal<class_Signal>` right **)** |
  45. +-------------------------+--------------------------------------------------------------------------------------------------+
  46. | :ref:`bool<class_bool>` | :ref:`operator ==<class_Signal_operator_eq_bool>` **(** **)** |
  47. +-------------------------+--------------------------------------------------------------------------------------------------+
  48. | :ref:`bool<class_bool>` | :ref:`operator ==<class_Signal_operator_eq_bool>` **(** :ref:`Signal<class_Signal>` right **)** |
  49. +-------------------------+--------------------------------------------------------------------------------------------------+
  50. Constructor Descriptions
  51. ------------------------
  52. .. _class_Signal_constructor_Signal:
  53. - :ref:`Signal<class_Signal>` **Signal** **(** **)**
  54. Constructs a null ``Signal`` with no object nor signal name bound.
  55. ----
  56. - :ref:`Signal<class_Signal>` **Signal** **(** :ref:`Signal<class_Signal>` from **)**
  57. Constructs a ``Signal`` as a copy of the given ``Signal``.
  58. ----
  59. - :ref:`Signal<class_Signal>` **Signal** **(** :ref:`Object<class_Object>` object, :ref:`StringName<class_StringName>` signal **)**
  60. Creates a new ``Signal`` with the name ``signal`` in the specified ``object``.
  61. Method Descriptions
  62. -------------------
  63. .. _class_Signal_method_connect:
  64. - :ref:`int<class_int>` **connect** **(** :ref:`Callable<class_Callable>` callable, :ref:`int<class_int>` flags=0 **)**
  65. 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>`.
  66. ::
  67. for button in $Buttons.get_children():
  68. button.pressed.connect(on_pressed.bind(button))
  69. func on_pressed(button):
  70. print(button.name, " was pressed")
  71. ----
  72. .. _class_Signal_method_disconnect:
  73. - void **disconnect** **(** :ref:`Callable<class_Callable>` callable **)**
  74. Disconnects this signal from the specified :ref:`Callable<class_Callable>`.
  75. ----
  76. .. _class_Signal_method_emit:
  77. - void **emit** **(** ... **)** |vararg| |const|
  78. Emits this signal to all connected objects.
  79. ----
  80. .. _class_Signal_method_get_connections:
  81. - :ref:`Array<class_Array>` **get_connections** **(** **)** |const|
  82. Returns the list of :ref:`Callable<class_Callable>`\ s connected to this signal.
  83. ----
  84. .. _class_Signal_method_get_name:
  85. - :ref:`StringName<class_StringName>` **get_name** **(** **)** |const|
  86. Returns the name of this signal.
  87. ----
  88. .. _class_Signal_method_get_object:
  89. - :ref:`Object<class_Object>` **get_object** **(** **)** |const|
  90. Returns the object emitting this signal.
  91. ----
  92. .. _class_Signal_method_get_object_id:
  93. - :ref:`int<class_int>` **get_object_id** **(** **)** |const|
  94. Returns the ID of the object emitting this signal (see :ref:`Object.get_instance_id<class_Object_method_get_instance_id>`).
  95. ----
  96. .. _class_Signal_method_is_connected:
  97. - :ref:`bool<class_bool>` **is_connected** **(** :ref:`Callable<class_Callable>` callable **)** |const|
  98. Returns ``true`` if the specified :ref:`Callable<class_Callable>` is connected to this signal.
  99. ----
  100. .. _class_Signal_method_is_null:
  101. - :ref:`bool<class_bool>` **is_null** **(** **)** |const|
  102. Operator Descriptions
  103. ---------------------
  104. .. _class_Signal_operator_neq_bool:
  105. - :ref:`bool<class_bool>` **operator !=** **(** **)**
  106. ----
  107. - :ref:`bool<class_bool>` **operator !=** **(** :ref:`Signal<class_Signal>` right **)**
  108. ----
  109. .. _class_Signal_operator_eq_bool:
  110. - :ref:`bool<class_bool>` **operator ==** **(** **)**
  111. ----
  112. - :ref:`bool<class_bool>` **operator ==** **(** :ref:`Signal<class_Signal>` right **)**
  113. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  114. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  115. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  116. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  117. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  118. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`