Skip to content

Commit ef817d5

Browse files
PaperomoAThousandShipsCalinou
authored
Update object_class.rst , updating connect()'s code sample and relevant explanation (#11341)
* Update object_class.rst should be updated and working * Update object_class.rst typos * Apply suggestions from code review --------- Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
1 parent 4dac167 commit ef817d5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

engine_details/architecture/object_class.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,15 @@ languages). This example shows how to connect to them:
227227

228228
.. code-block:: cpp
229229
230-
obj->connect(<signal>, target_instance, target_method)
231-
// for example:
232-
obj->connect("enter_tree", this, "_node_entered_tree")
233-
234-
The method ``_node_entered_tree`` must be registered to the class using
235-
``ClassDB::bind_method`` (explained before).
230+
// This is the function signature:
231+
//
232+
// Error connect(const StringName &p_signal, const Callable &p_callable, uint32_t p_flags = 0)
233+
//
234+
// For example:
235+
obj->connect("signal_name_here", callable_mp(this, &MyCustomType::method), CONNECT_DEFERRED);
236+
237+
``callable_mp`` is a macro to create a custom callable function pointer to member functions.
238+
For the values of ``p_flags``, see :ref:`ConnectFlags <enum_Object_ConnectFlags>`.
236239

237240
Adding signals to a class is done in ``_bind_methods``, using the
238241
``ADD_SIGNAL`` macro, for example:

0 commit comments

Comments
 (0)