class_editorresourcepicker.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the EditorResourcePicker.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_EditorResourcePicker:
  6. EditorResourcePicker
  7. ====================
  8. **Inherits:** :ref:`HBoxContainer<class_HBoxContainer>` **<** :ref:`BoxContainer<class_BoxContainer>` **<** :ref:`Container<class_Container>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`EditorScriptPicker<class_EditorScriptPicker>`
  10. Godot editor's control for selecting :ref:`Resource<class_Resource>` type properties.
  11. Description
  12. -----------
  13. This :ref:`Control<class_Control>` node is used in the editor's Inspector dock to allow editing of :ref:`Resource<class_Resource>` type properties. It provides options for creating, loading, saving and converting resources. Can be used with :ref:`EditorInspectorPlugin<class_EditorInspectorPlugin>` to recreate the same behavior.
  14. **Note:** This :ref:`Control<class_Control>` does not include any editor for the resource, as editing is controlled by the Inspector dock itself or sub-Inspectors.
  15. Properties
  16. ----------
  17. +---------------------------------+-----------------------------------------------------------------------------+-----------+
  18. | :ref:`String<class_String>` | :ref:`base_type<class_EditorResourcePicker_property_base_type>` | ``""`` |
  19. +---------------------------------+-----------------------------------------------------------------------------+-----------+
  20. | :ref:`bool<class_bool>` | :ref:`editable<class_EditorResourcePicker_property_editable>` | ``true`` |
  21. +---------------------------------+-----------------------------------------------------------------------------+-----------+
  22. | :ref:`Resource<class_Resource>` | :ref:`edited_resource<class_EditorResourcePicker_property_edited_resource>` | |
  23. +---------------------------------+-----------------------------------------------------------------------------+-----------+
  24. | :ref:`bool<class_bool>` | :ref:`toggle_mode<class_EditorResourcePicker_property_toggle_mode>` | ``false`` |
  25. +---------------------------------+-----------------------------------------------------------------------------+-----------+
  26. Methods
  27. -------
  28. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`can_drop_data_fw<class_EditorResourcePicker_method_can_drop_data_fw>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`Variant<class_Variant>` data, :ref:`Control<class_Control>` from **)** |const| |
  30. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`drop_data_fw<class_EditorResourcePicker_method_drop_data_fw>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`Variant<class_Variant>` data, :ref:`Control<class_Control>` from **)** |
  32. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_allowed_types<class_EditorResourcePicker_method_get_allowed_types>` **(** **)** |const| |
  34. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Variant<class_Variant>` | :ref:`get_drag_data_fw<class_EditorResourcePicker_method_get_drag_data_fw>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`Control<class_Control>` from **)** |
  36. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`handle_menu_selected<class_EditorResourcePicker_method_handle_menu_selected>` **(** :ref:`int<class_int>` id **)** |virtual| |
  38. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`set_create_options<class_EditorResourcePicker_method_set_create_options>` **(** :ref:`Object<class_Object>` menu_node **)** |virtual| |
  40. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`set_toggle_pressed<class_EditorResourcePicker_method_set_toggle_pressed>` **(** :ref:`bool<class_bool>` pressed **)** |
  42. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. Signals
  44. -------
  45. .. _class_EditorResourcePicker_signal_resource_changed:
  46. - **resource_changed** **(** :ref:`Resource<class_Resource>` resource **)**
  47. Emitted when the value of the edited resource was changed.
  48. ----
  49. .. _class_EditorResourcePicker_signal_resource_selected:
  50. - **resource_selected** **(** :ref:`Resource<class_Resource>` resource, :ref:`bool<class_bool>` edit **)**
  51. Emitted when the resource value was set and user clicked to edit it. When ``edit`` is ``true``, the signal was caused by the context menu "Edit" option.
  52. Property Descriptions
  53. ---------------------
  54. .. _class_EditorResourcePicker_property_base_type:
  55. - :ref:`String<class_String>` **base_type**
  56. +-----------+----------------------+
  57. | *Default* | ``""`` |
  58. +-----------+----------------------+
  59. | *Setter* | set_base_type(value) |
  60. +-----------+----------------------+
  61. | *Getter* | get_base_type() |
  62. +-----------+----------------------+
  63. The base type of allowed resource types. Can be a comma-separated list of several options.
  64. ----
  65. .. _class_EditorResourcePicker_property_editable:
  66. - :ref:`bool<class_bool>` **editable**
  67. +-----------+---------------------+
  68. | *Default* | ``true`` |
  69. +-----------+---------------------+
  70. | *Setter* | set_editable(value) |
  71. +-----------+---------------------+
  72. | *Getter* | is_editable() |
  73. +-----------+---------------------+
  74. If ``true``, the value can be selected and edited.
  75. ----
  76. .. _class_EditorResourcePicker_property_edited_resource:
  77. - :ref:`Resource<class_Resource>` **edited_resource**
  78. +----------+----------------------------+
  79. | *Setter* | set_edited_resource(value) |
  80. +----------+----------------------------+
  81. | *Getter* | get_edited_resource() |
  82. +----------+----------------------------+
  83. The edited resource value.
  84. ----
  85. .. _class_EditorResourcePicker_property_toggle_mode:
  86. - :ref:`bool<class_bool>` **toggle_mode**
  87. +-----------+------------------------+
  88. | *Default* | ``false`` |
  89. +-----------+------------------------+
  90. | *Setter* | set_toggle_mode(value) |
  91. +-----------+------------------------+
  92. | *Getter* | is_toggle_mode() |
  93. +-----------+------------------------+
  94. If ``true``, the main button with the resource preview works in the toggle mode. Use :ref:`set_toggle_pressed<class_EditorResourcePicker_method_set_toggle_pressed>` to manually set the state.
  95. Method Descriptions
  96. -------------------
  97. .. _class_EditorResourcePicker_method_can_drop_data_fw:
  98. - :ref:`bool<class_bool>` **can_drop_data_fw** **(** :ref:`Vector2<class_Vector2>` position, :ref:`Variant<class_Variant>` data, :ref:`Control<class_Control>` from **)** |const|
  99. ----
  100. .. _class_EditorResourcePicker_method_drop_data_fw:
  101. - void **drop_data_fw** **(** :ref:`Vector2<class_Vector2>` position, :ref:`Variant<class_Variant>` data, :ref:`Control<class_Control>` from **)**
  102. ----
  103. .. _class_EditorResourcePicker_method_get_allowed_types:
  104. - :ref:`PoolStringArray<class_PoolStringArray>` **get_allowed_types** **(** **)** |const|
  105. Returns a list of all allowed types and subtypes corresponding to the :ref:`base_type<class_EditorResourcePicker_property_base_type>`. If the :ref:`base_type<class_EditorResourcePicker_property_base_type>` is empty, an empty list is returned.
  106. ----
  107. .. _class_EditorResourcePicker_method_get_drag_data_fw:
  108. - :ref:`Variant<class_Variant>` **get_drag_data_fw** **(** :ref:`Vector2<class_Vector2>` position, :ref:`Control<class_Control>` from **)**
  109. ----
  110. .. _class_EditorResourcePicker_method_handle_menu_selected:
  111. - void **handle_menu_selected** **(** :ref:`int<class_int>` id **)** |virtual|
  112. This virtual method can be implemented to handle context menu items not handled by default. See :ref:`set_create_options<class_EditorResourcePicker_method_set_create_options>`.
  113. ----
  114. .. _class_EditorResourcePicker_method_set_create_options:
  115. - void **set_create_options** **(** :ref:`Object<class_Object>` menu_node **)** |virtual|
  116. This virtual method is called when updating the context menu of ``EditorResourcePicker``. Implement this method to override the "New ..." items with your own options. ``menu_node`` is a reference to the :ref:`PopupMenu<class_PopupMenu>` node.
  117. **Note:** Implement :ref:`handle_menu_selected<class_EditorResourcePicker_method_handle_menu_selected>` to handle these custom items.
  118. ----
  119. .. _class_EditorResourcePicker_method_set_toggle_pressed:
  120. - void **set_toggle_pressed** **(** :ref:`bool<class_bool>` pressed **)**
  121. Sets the toggle mode state for the main button. Works only if :ref:`toggle_mode<class_EditorResourcePicker_property_toggle_mode>` is set to ``true``.
  122. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  123. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  124. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`