소스 검색

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 <[email protected]>
Co-authored-by: Hugo Locurcio <[email protected]>
Paperomo 1 주 전
부모
커밋
ef817d5ddf
1개의 변경된 파일9개의 추가작업 그리고 6개의 파일을 삭제
  1. 9 6
      engine_details/architecture/object_class.rst

+ 9 - 6
engine_details/architecture/object_class.rst

@@ -227,12 +227,15 @@ languages). This example shows how to connect to them:
 
 .. code-block:: cpp
 
-    obj->connect(<signal>, target_instance, target_method)
-    // for example:
-    obj->connect("enter_tree", this, "_node_entered_tree")
-
-The method ``_node_entered_tree`` must be registered to the class using
-``ClassDB::bind_method`` (explained before).
+    // This is the function signature:
+    //
+    // Error connect(const StringName &p_signal, const Callable &p_callable, uint32_t p_flags = 0)
+    //
+    // For example:
+    obj->connect("signal_name_here", callable_mp(this, &MyCustomType::method), CONNECT_DEFERRED);
+
+``callable_mp`` is a macro to create a custom callable function pointer to member functions.
+For the values of ``p_flags``, see :ref:`ConnectFlags <enum_Object_ConnectFlags>`.
 
 Adding signals to a class is done in ``_bind_methods``, using the
 ``ADD_SIGNAL`` macro, for example: