Files
godot-docs/classes/class_editorcontextmenuplugin.rst
2024-09-07 03:20:35 +00:00

105 lines
5.8 KiB
ReStructuredText

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/EditorContextMenuPlugin.xml.
.. _class_EditorContextMenuPlugin:
EditorContextMenuPlugin
=======================
**Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
Plugin for adding custom context menus in the editor.
.. rst-class:: classref-introduction-group
Description
-----------
**EditorContextMenuPlugin** allows for the addition of custom options in the editor's context menu.
Currently, context menus are supported for three commonly used areas: the file system, scene tree, and editor script list panel.
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`_popup_menu<class_EditorContextMenuPlugin_private_method__popup_menu>`\ (\ paths\: :ref:`PackedStringArray<class_PackedStringArray>`\ ) |virtual| |
+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |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\ ) |
+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`add_menu_shortcut<class_EditorContextMenuPlugin_method_add_menu_shortcut>`\ (\ shortcut\: :ref:`Shortcut<class_Shortcut>`, callback\: :ref:`Callable<class_Callable>`\ ) |
+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_EditorContextMenuPlugin_private_method__popup_menu:
.. rst-class:: classref-method
|void| **_popup_menu**\ (\ paths\: :ref:`PackedStringArray<class_PackedStringArray>`\ ) |virtual| :ref:`🔗<class_EditorContextMenuPlugin_private_method__popup_menu>`
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.
.. rst-class:: classref-item-separator
----
.. _class_EditorContextMenuPlugin_method_add_context_menu_item:
.. rst-class:: classref-method
|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>`
Add custom options to the context menu of the currently specified slot.
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.
::
func _popup_menu(paths):
add_context_menu_item("File Custom options", handle, ICON)
.. rst-class:: classref-item-separator
----
.. _class_EditorContextMenuPlugin_method_add_menu_shortcut:
.. rst-class:: classref-method
|void| **add_menu_shortcut**\ (\ shortcut\: :ref:`Shortcut<class_Shortcut>`, callback\: :ref:`Callable<class_Callable>`\ ) :ref:`🔗<class_EditorContextMenuPlugin_method_add_menu_shortcut>`
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.
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.
::
func _init():
add_menu_shortcut(SHORTCUT, handle);
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
.. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
.. |void| replace:: :abbr:`void (No return value.)`