mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
129 lines
6.5 KiB
ReStructuredText
129 lines
6.5 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
|
|
.. DO NOT EDIT THIS FILE, but the Callable.xml source instead.
|
|
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
|
|
|
.. _class_Callable:
|
|
|
|
Callable
|
|
========
|
|
|
|
An object representing a method in a certain object that can be called.
|
|
|
|
Description
|
|
-----------
|
|
|
|
``Callable`` is a first class object which can be held in variables and passed to functions. It represents a given method in an :ref:`Object<class_Object>`, and is typically used for signal callbacks.
|
|
|
|
**Example:**
|
|
|
|
::
|
|
|
|
var callable = Callable(self, "print_args")
|
|
func print_args(arg1, arg2, arg3 = ""):
|
|
prints(arg1, arg2, arg3)
|
|
func test():
|
|
callable.call("hello", "world") # Prints "hello world".
|
|
callable.call(Vector2.UP, 42, callable) # Prints "(0, -1) 42 Node(Node.gd)::print_args".
|
|
callable.call("invalid") # Invalid call, should have at least 2 arguments.
|
|
|
|
Methods
|
|
-------
|
|
|
|
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Callable<class_Callable>` | :ref:`Callable<class_Callable_method_Callable>` **(** :ref:`Object<class_Object>` object, :ref:`StringName<class_StringName>` method_name **)** |
|
|
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Variant<class_Variant>` | :ref:`call<class_Callable_method_call>` **(** ... **)** vararg |
|
|
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`call_deferred<class_Callable_method_call_deferred>` **(** ... **)** vararg |
|
|
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`StringName<class_StringName>` | :ref:`get_method<class_Callable_method_get_method>` **(** **)** |
|
|
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Object<class_Object>` | :ref:`get_object<class_Callable_method_get_object>` **(** **)** |
|
|
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_object_id<class_Callable_method_get_object_id>` **(** **)** |
|
|
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`hash<class_Callable_method_hash>` **(** **)** |
|
|
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_custom<class_Callable_method_is_custom>` **(** **)** |
|
|
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_null<class_Callable_method_is_null>` **(** **)** |
|
|
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_standard<class_Callable_method_is_standard>` **(** **)** |
|
|
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_Callable_method_Callable:
|
|
|
|
- :ref:`Callable<class_Callable>` **Callable** **(** :ref:`Object<class_Object>` object, :ref:`StringName<class_StringName>` method_name **)**
|
|
|
|
Creates a new ``Callable`` for the method called ``method_name`` in the specified ``object``.
|
|
|
|
----
|
|
|
|
.. _class_Callable_method_call:
|
|
|
|
- :ref:`Variant<class_Variant>` **call** **(** ... **)** vararg
|
|
|
|
Calls the method represented by this ``Callable``. Arguments can be passed and should match the method's signature.
|
|
|
|
----
|
|
|
|
.. _class_Callable_method_call_deferred:
|
|
|
|
- void **call_deferred** **(** ... **)** vararg
|
|
|
|
Calls the method represented by this ``Callable`` in deferred mode, i.e. during the idle frame. Arguments can be passed and should match the method's signature.
|
|
|
|
----
|
|
|
|
.. _class_Callable_method_get_method:
|
|
|
|
- :ref:`StringName<class_StringName>` **get_method** **(** **)**
|
|
|
|
Returns the name of the method represented by this ``Callable``.
|
|
|
|
----
|
|
|
|
.. _class_Callable_method_get_object:
|
|
|
|
- :ref:`Object<class_Object>` **get_object** **(** **)**
|
|
|
|
Returns the object on which this ``Callable`` is called.
|
|
|
|
----
|
|
|
|
.. _class_Callable_method_get_object_id:
|
|
|
|
- :ref:`int<class_int>` **get_object_id** **(** **)**
|
|
|
|
Returns the ID of this ``Callable``'s object (see :ref:`Object.get_instance_id<class_Object_method_get_instance_id>`).
|
|
|
|
----
|
|
|
|
.. _class_Callable_method_hash:
|
|
|
|
- :ref:`int<class_int>` **hash** **(** **)**
|
|
|
|
----
|
|
|
|
.. _class_Callable_method_is_custom:
|
|
|
|
- :ref:`bool<class_bool>` **is_custom** **(** **)**
|
|
|
|
----
|
|
|
|
.. _class_Callable_method_is_null:
|
|
|
|
- :ref:`bool<class_bool>` **is_null** **(** **)**
|
|
|
|
----
|
|
|
|
.. _class_Callable_method_is_standard:
|
|
|
|
- :ref:`bool<class_bool>` **is_standard** **(** **)**
|
|
|