godot/doc/classes/Callable.xml

159 lines
4.4 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="UTF-8" ?>
<class name="Callable" version="4.0">
<brief_description>
2020-03-04 02:21:21 +08:00
An object representing a method in a certain object that can be called.
</brief_description>
<description>
2020-03-04 02:21:21 +08:00
[Callable] is a first class object which can be held in variables and passed to functions. It represents a given method in an [Object], and is typically used for signal callbacks.
[b]Example:[/b]
[codeblocks]
[gdscript]
2020-03-04 02:21:21 +08:00
var callable = Callable(self, "print_args")
func print_args(arg1, arg2, arg3 = ""):
prints(arg1, arg2, arg3)
2020-03-04 02:21:21 +08:00
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.
[/gdscript]
[csharp]
Callable callable = new Callable(this, "print_args");
public void PrintArgs(object arg1, object arg2, object arg3 = "")
{
GD.PrintS(arg1, arg2, arg3);
}
public void 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.
}
[/csharp]
[/codeblocks]
</description>
<tutorials>
</tutorials>
<methods>
<method name="Callable" qualifiers="constructor">
<return type="Callable">
</return>
<description>
Constructs a null [Callable] with no object nor method bound.
</description>
</method>
<method name="Callable" qualifiers="constructor">
<return type="Callable">
</return>
<argument index="0" name="from" type="Callable">
</argument>
<description>
Constructs a [Callable] as a copy of the given [Callable].
</description>
</method>
<method name="Callable" qualifiers="constructor">
<return type="Callable">
</return>
<argument index="0" name="object" type="Object">
</argument>
<argument index="1" name="method" type="StringName">
</argument>
<description>
Creates a new [Callable] for the method called [code]method[/code] in the specified [code]object[/code].
</description>
</method>
2020-10-12 16:57:54 +08:00
<method name="bind" qualifiers="vararg">
<return type="Callable">
2020-10-12 16:57:54 +08:00
</return>
<description>
</description>
</method>
<method name="call" qualifiers="vararg">
<return type="Variant">
</return>
<description>
2020-03-04 02:21:21 +08:00
Calls the method represented by this [Callable]. Arguments can be passed and should match the method's signature.
</description>
</method>
<method name="call_deferred" qualifiers="vararg">
<return type="void">
</return>
<description>
2020-03-04 02:21:21 +08:00
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.
</description>
</method>
<method name="get_method">
<return type="StringName">
</return>
<description>
2020-03-04 02:21:21 +08:00
Returns the name of the method represented by this [Callable].
</description>
</method>
<method name="get_object">
<return type="Object">
</return>
<description>
2020-03-04 02:21:21 +08:00
Returns the object on which this [Callable] is called.
</description>
</method>
<method name="get_object_id">
<return type="int">
</return>
<description>
2020-03-04 02:21:21 +08:00
Returns the ID of this [Callable]'s object (see [method Object.get_instance_id]).
</description>
</method>
<method name="hash">
<return type="int">
</return>
<description>
</description>
</method>
<method name="is_custom">
<return type="bool">
</return>
<description>
</description>
</method>
<method name="is_null">
<return type="bool">
</return>
<description>
</description>
</method>
<method name="is_standard">
<return type="bool">
</return>
<description>
</description>
</method>
<method name="operator !=" qualifiers="operator">
<return type="bool">
</return>
<argument index="0" name="right" type="Callable">
</argument>
<description>
</description>
</method>
<method name="operator ==" qualifiers="operator">
<return type="bool">
</return>
<argument index="0" name="right" type="Callable">
</argument>
<description>
</description>
</method>
2020-10-12 16:57:54 +08:00
<method name="unbind">
<return type="Callable">
</return>
<argument index="0" name="argcount" type="int">
</argument>
<description>
</description>
</method>
</methods>
<constants>
</constants>
</class>