Class EditorContextMenuPlugin
- Namespace
- Godot
- Assembly
- GodotSharpEditor.dll
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.
public class EditorContextMenuPlugin : RefCounted, IDisposable
- Inheritance
-
EditorContextMenuPlugin
- Implements
- Inherited Members
Constructors
EditorContextMenuPlugin()
public EditorContextMenuPlugin()
Methods
AddContextMenuItem(string, Callable, Texture2D)
Add custom option to the context menu of the plugin's specified slot. When the option is activated, callback will be called. Callback should take single Array argument; array contents depend on context menu slot.
func _popup_menu(paths):
add_context_menu_item("File Custom options", handle, ICON)
If you want to assign shortcut to the menu item, use AddContextMenuItemFromShortcut(string, Shortcut, Texture2D) instead.
public void AddContextMenuItem(string name, Callable callback, Texture2D icon = null)
Parameters
AddContextMenuItemFromShortcut(string, Shortcut, Texture2D)
Add custom option to the context menu of the plugin's specified slot. The option will have the shortcut assigned and reuse its callback. The shortcut has to be registered beforehand with AddMenuShortcut(Shortcut, Callable).
func _init():
add_menu_shortcut(SHORTCUT, handle)
func _popup_menu(paths):
add_context_menu_item_from_shortcut("File Custom options", SHORTCUT, ICON)
public void AddContextMenuItemFromShortcut(string name, Shortcut shortcut, Texture2D icon = null)
Parameters
AddContextSubmenuItem(string, PopupMenu, Texture2D)
Add a submenu to the context menu of the plugin's specified slot. The submenu is not automatically handled, you need to connect to its signals yourself. Also the submenu is freed on every popup, so provide a new PopupMenu every time.
func _popup_menu(paths):
var popup_menu = PopupMenu.new()
popup_menu.add_item("Blue")
popup_menu.add_item("White")
popup_menu.id_pressed.connect(_on_color_submenu_option)
add_context_submenu_item("Set Node Color", popup_menu)</code></pre>
public void AddContextSubmenuItem(string name, PopupMenu menu, Texture2D icon = null)
Parameters
AddMenuShortcut(Shortcut, Callable)
Registers a shortcut associated with the plugin's context menu. This method should be called once (e.g. in plugin's GodotObject()). callback will be called when user presses the specified shortcut while the menu's context is in effect (e.g. FileSystem dock is focused). Callback should take single Array argument; array contents depend on context menu slot.
func _init():
add_menu_shortcut(SHORTCUT, handle)
public void AddMenuShortcut(Shortcut shortcut, Callable callback)
Parameters
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
methodgodot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signalgodot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
methodgodot_string_nameName of the method to invoke.
argsNativeVariantPtrArgsArguments to use with the invoked method.
retgodot_variantValue returned by the invoked method.
Returns
_PopupMenu(string[])
Called when creating a context menu, custom options can be added by using the AddContextMenuItem(string, Callable, Texture2D) or AddContextMenuItemFromShortcut(string, Shortcut, Texture2D) functions. paths contains currently selected paths (depending on menu), which can be used to conditionally add options.
public virtual void _PopupMenu(string[] paths)
Parameters
pathsstring[]