123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- :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** **(** **)**
|