class_graphedit.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the GraphEdit.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_GraphEdit:
  5. GraphEdit
  6. =========
  7. **Inherits:** :ref:`Control<class_control>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. GraphEdit is an area capable of showing various GraphNodes. It manages connection events between them.
  12. Member Functions
  13. ----------------
  14. +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | void | :ref:`add_valid_connection_type<class_GraphEdit_add_valid_connection_type>` **(** :ref:`int<class_int>` from_type, :ref:`int<class_int>` to_type **)** |
  16. +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`add_valid_left_disconnect_type<class_GraphEdit_add_valid_left_disconnect_type>` **(** :ref:`int<class_int>` type **)** |
  18. +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`add_valid_right_disconnect_type<class_GraphEdit_add_valid_right_disconnect_type>` **(** :ref:`int<class_int>` type **)** |
  20. +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`clear_connections<class_GraphEdit_clear_connections>` **(** **)** |
  22. +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`int<class_int>` | :ref:`connect_node<class_GraphEdit_connect_node>` **(** :ref:`String<class_string>` from, :ref:`int<class_int>` from_port, :ref:`String<class_string>` to, :ref:`int<class_int>` to_port **)** |
  24. +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`disconnect_node<class_GraphEdit_disconnect_node>` **(** :ref:`String<class_string>` from, :ref:`int<class_int>` from_port, :ref:`String<class_string>` to, :ref:`int<class_int>` to_port **)** |
  26. +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Array<class_array>` | :ref:`get_connection_list<class_GraphEdit_get_connection_list>` **(** **)** const |
  28. +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`is_node_connected<class_GraphEdit_is_node_connected>` **(** :ref:`String<class_string>` from, :ref:`int<class_int>` from_port, :ref:`String<class_string>` to, :ref:`int<class_int>` to_port **)** |
  30. +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`is_valid_connection_type<class_GraphEdit_is_valid_connection_type>` **(** :ref:`int<class_int>` from_type, :ref:`int<class_int>` to_type **)** const |
  32. +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`remove_valid_connection_type<class_GraphEdit_remove_valid_connection_type>` **(** :ref:`int<class_int>` from_type, :ref:`int<class_int>` to_type **)** |
  34. +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`remove_valid_left_disconnect_type<class_GraphEdit_remove_valid_left_disconnect_type>` **(** :ref:`int<class_int>` type **)** |
  36. +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`remove_valid_right_disconnect_type<class_GraphEdit_remove_valid_right_disconnect_type>` **(** :ref:`int<class_int>` type **)** |
  38. +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`set_selected<class_GraphEdit_set_selected>` **(** :ref:`Node<class_node>` node **)** |
  40. +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. Signals
  42. -------
  43. .. _class_GraphEdit__begin_node_move:
  44. - **_begin_node_move** **(** **)**
  45. Signal sent at the beginning of a GraphNode movement.
  46. .. _class_GraphEdit__end_node_move:
  47. - **_end_node_move** **(** **)**
  48. Signal sent at the end of a GraphNode movement.
  49. .. _class_GraphEdit_connection_request:
  50. - **connection_request** **(** :ref:`String<class_string>` from, :ref:`int<class_int>` from_slot, :ref:`String<class_string>` to, :ref:`int<class_int>` to_slot **)**
  51. Signal sent to the GraphEdit when the connection between 'from_slot' slot of 'from' GraphNode and 'to_slot' slot of 'to' GraphNode is attempted to be created.
  52. .. _class_GraphEdit_connection_to_empty:
  53. - **connection_to_empty** **(** :ref:`String<class_string>` from, :ref:`int<class_int>` from_slot, :ref:`Vector2<class_vector2>` release_position **)**
  54. .. _class_GraphEdit_delete_nodes_request:
  55. - **delete_nodes_request** **(** **)**
  56. Signal sent when a GraphNode is attempted to be removed from the GraphEdit.
  57. .. _class_GraphEdit_disconnection_request:
  58. - **disconnection_request** **(** :ref:`String<class_string>` from, :ref:`int<class_int>` from_slot, :ref:`String<class_string>` to, :ref:`int<class_int>` to_slot **)**
  59. Signal sent to the GraphEdit when the connection between 'from_slot' slot of 'from' GraphNode and 'to_slot' slot of 'to' GraphNode is attempted to be removed.
  60. .. _class_GraphEdit_duplicate_nodes_request:
  61. - **duplicate_nodes_request** **(** **)**
  62. Signal sent when a GraphNode is attempted to be duplicated in the GraphEdit.
  63. .. _class_GraphEdit_node_selected:
  64. - **node_selected** **(** :ref:`Object<class_object>` node **)**
  65. Emitted when a GraphNode is selected.
  66. .. _class_GraphEdit_popup_request:
  67. - **popup_request** **(** :ref:`Vector2<class_vector2>` p_position **)**
  68. Signal sent when a popup is requested. Happens on right-clicking in the GraphEdit. 'p_position' is the position of the mouse pointer when the signal is sent.
  69. .. _class_GraphEdit_scroll_offset_changed:
  70. - **scroll_offset_changed** **(** :ref:`Vector2<class_vector2>` ofs **)**
  71. Member Variables
  72. ----------------
  73. .. _class_GraphEdit_right_disconnects:
  74. - :ref:`bool<class_bool>` **right_disconnects** - If ``true``, enables disconnection of existing connections in the GraphEdit by dragging the right end.
  75. .. _class_GraphEdit_scroll_offset:
  76. - :ref:`Vector2<class_vector2>` **scroll_offset** - The scroll offset.
  77. .. _class_GraphEdit_snap_distance:
  78. - :ref:`int<class_int>` **snap_distance** - The snapping distance in pixels.
  79. .. _class_GraphEdit_use_snap:
  80. - :ref:`bool<class_bool>` **use_snap** - If ``true``, enables snapping.
  81. .. _class_GraphEdit_zoom:
  82. - :ref:`float<class_float>` **zoom** - The current zoom value.
  83. Description
  84. -----------
  85. GraphEdit manages the showing of GraphNodes it contains, as well as connections and disconnections between them. Signals are sent for each of these two events. Disconnection between GraphNodes slots is disabled by default.
  86. It is greatly advised to enable low processor usage mode (see :ref:`OS.set_low_processor_usage_mode<class_OS_set_low_processor_usage_mode>`) when using GraphEdits.
  87. Member Function Description
  88. ---------------------------
  89. .. _class_GraphEdit_add_valid_connection_type:
  90. - void **add_valid_connection_type** **(** :ref:`int<class_int>` from_type, :ref:`int<class_int>` to_type **)**
  91. Makes possible the connection between two different slot types. The type is defined with the :ref:`GraphNode.set_slot<class_GraphNode_set_slot>` method.
  92. .. _class_GraphEdit_add_valid_left_disconnect_type:
  93. - void **add_valid_left_disconnect_type** **(** :ref:`int<class_int>` type **)**
  94. Makes possible to disconnect nodes when dragging from the slot at the left if it has the specified type.
  95. .. _class_GraphEdit_add_valid_right_disconnect_type:
  96. - void **add_valid_right_disconnect_type** **(** :ref:`int<class_int>` type **)**
  97. Makes possible to disconnect nodes when dragging from the slot at the right if it has the specified type.
  98. .. _class_GraphEdit_clear_connections:
  99. - void **clear_connections** **(** **)**
  100. Remove all connections between nodes.
  101. .. _class_GraphEdit_connect_node:
  102. - :ref:`int<class_int>` **connect_node** **(** :ref:`String<class_string>` from, :ref:`int<class_int>` from_port, :ref:`String<class_string>` to, :ref:`int<class_int>` to_port **)**
  103. Create a connection between 'from_port' slot of 'from' GraphNode and 'to_port' slot of 'to' GraphNode. If the connection already exists, no connection is created.
  104. .. _class_GraphEdit_disconnect_node:
  105. - void **disconnect_node** **(** :ref:`String<class_string>` from, :ref:`int<class_int>` from_port, :ref:`String<class_string>` to, :ref:`int<class_int>` to_port **)**
  106. Remove the connection between 'from_port' slot of 'from' GraphNode and 'to_port' slot of 'to' GraphNode, if connection exists.
  107. .. _class_GraphEdit_get_connection_list:
  108. - :ref:`Array<class_array>` **get_connection_list** **(** **)** const
  109. Return an Array containing the list of connections. A connection consists in a structure of the form {from_slot: 0, from: "GraphNode name 0", to_slot: 1, to: "GraphNode name 1" }
  110. .. _class_GraphEdit_is_node_connected:
  111. - :ref:`bool<class_bool>` **is_node_connected** **(** :ref:`String<class_string>` from, :ref:`int<class_int>` from_port, :ref:`String<class_string>` to, :ref:`int<class_int>` to_port **)**
  112. Return true if the 'from_port' slot of 'from' GraphNode is connected to the 'to_port' slot of 'to' GraphNode.
  113. .. _class_GraphEdit_is_valid_connection_type:
  114. - :ref:`bool<class_bool>` **is_valid_connection_type** **(** :ref:`int<class_int>` from_type, :ref:`int<class_int>` to_type **)** const
  115. Returns whether it's possible to connect slots of the specified types.
  116. .. _class_GraphEdit_remove_valid_connection_type:
  117. - void **remove_valid_connection_type** **(** :ref:`int<class_int>` from_type, :ref:`int<class_int>` to_type **)**
  118. Makes it not possible to connect between two different slot types. The type is defined with the :ref:`GraphNode.set_slot<class_GraphNode_set_slot>` method.
  119. .. _class_GraphEdit_remove_valid_left_disconnect_type:
  120. - void **remove_valid_left_disconnect_type** **(** :ref:`int<class_int>` type **)**
  121. Removes the possibility to disconnect nodes when dragging from the slot at the left if it has the specified type.
  122. .. _class_GraphEdit_remove_valid_right_disconnect_type:
  123. - void **remove_valid_right_disconnect_type** **(** :ref:`int<class_int>` type **)**
  124. Removes the possibility to disconnect nodes when dragging from the slot at the right if it has the specified type.
  125. .. _class_GraphEdit_set_selected:
  126. - void **set_selected** **(** :ref:`Node<class_node>` node **)**
  127. Sets the specified ``node`` as the one selected.