class_editorcontextmenuplugin.rst 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/EditorContextMenuPlugin.xml.
  6. .. _class_EditorContextMenuPlugin:
  7. EditorContextMenuPlugin
  8. =======================
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Plugin for adding custom context menus in the editor.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. **EditorContextMenuPlugin** allows for the addition of custom options in the editor's context menu.
  15. Currently, context menus are supported for three commonly used areas: the file system, scene tree, and editor script list panel.
  16. .. rst-class:: classref-reftable-group
  17. Methods
  18. -------
  19. .. table::
  20. :widths: auto
  21. +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | |void| | :ref:`_popup_menu<class_EditorContextMenuPlugin_private_method__popup_menu>`\ (\ paths\: :ref:`PackedStringArray<class_PackedStringArray>`\ ) |virtual| |
  23. +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | |void| | :ref:`add_context_menu_item<class_EditorContextMenuPlugin_method_add_context_menu_item>`\ (\ name\: :ref:`String<class_String>`, callback\: :ref:`Callable<class_Callable>`, icon\: :ref:`Texture2D<class_Texture2D>` = null, shortcut\: :ref:`Shortcut<class_Shortcut>` = null\ ) |
  25. +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | |void| | :ref:`add_menu_shortcut<class_EditorContextMenuPlugin_method_add_menu_shortcut>`\ (\ shortcut\: :ref:`Shortcut<class_Shortcut>`, callback\: :ref:`Callable<class_Callable>`\ ) |
  27. +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. .. rst-class:: classref-section-separator
  29. ----
  30. .. rst-class:: classref-descriptions-group
  31. Method Descriptions
  32. -------------------
  33. .. _class_EditorContextMenuPlugin_private_method__popup_menu:
  34. .. rst-class:: classref-method
  35. |void| **_popup_menu**\ (\ paths\: :ref:`PackedStringArray<class_PackedStringArray>`\ ) |virtual| :ref:`🔗<class_EditorContextMenuPlugin_private_method__popup_menu>`
  36. Called when creating a context menu, custom options can be added by using the :ref:`add_context_menu_item<class_EditorContextMenuPlugin_method_add_context_menu_item>` function.
  37. .. rst-class:: classref-item-separator
  38. ----
  39. .. _class_EditorContextMenuPlugin_method_add_context_menu_item:
  40. .. rst-class:: classref-method
  41. |void| **add_context_menu_item**\ (\ name\: :ref:`String<class_String>`, callback\: :ref:`Callable<class_Callable>`, icon\: :ref:`Texture2D<class_Texture2D>` = null, shortcut\: :ref:`Shortcut<class_Shortcut>` = null\ ) :ref:`🔗<class_EditorContextMenuPlugin_method_add_context_menu_item>`
  42. Add custom options to the context menu of the currently specified slot.
  43. To trigger a ``shortcut`` before the context menu is created, please additionally call the :ref:`add_menu_shortcut<class_EditorContextMenuPlugin_method_add_menu_shortcut>` function.
  44. ::
  45. func _popup_menu(paths):
  46. add_context_menu_item("File Custom options", handle, ICON)
  47. .. rst-class:: classref-item-separator
  48. ----
  49. .. _class_EditorContextMenuPlugin_method_add_menu_shortcut:
  50. .. rst-class:: classref-method
  51. |void| **add_menu_shortcut**\ (\ shortcut\: :ref:`Shortcut<class_Shortcut>`, callback\: :ref:`Callable<class_Callable>`\ ) :ref:`🔗<class_EditorContextMenuPlugin_method_add_menu_shortcut>`
  52. To register the shortcut for the context menu, call this function within the :ref:`Object._init<class_Object_private_method__init>` function, even if the context menu has not been created yet.
  53. Note that this method should only be invoked from :ref:`Object._init<class_Object_private_method__init>`; otherwise, the shortcut will not be registered correctly.
  54. ::
  55. func _init():
  56. add_menu_shortcut(SHORTCUT, handle);
  57. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  58. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  59. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  60. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  61. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  62. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  63. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  64. .. |void| replace:: :abbr:`void (No return value.)`