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 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

Callable Callable ( Object object, StringName method_name )
Variant call () vararg
void call_deferred () vararg
StringName get_method ( )
Object get_object ( )
int get_object_id ( )
int hash ( )
bool is_custom ( )
bool is_null ( )
bool is_standard ( )

Method Descriptions

Creates a new Callable for the method called method_name in the specified object.


Calls the method represented by this Callable. Arguments can be passed and should match the method’s signature.


  • 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.


Returns the name of the method represented by this Callable.


Returns the object on which this Callable is called.


  • int get_object_id ( )

Returns the ID of this Callable’s object (see Object.get_instance_id).



  • bool is_custom ( )


  • bool is_standard ( )