EditorContextMenuPlugin
Plugin for adding custom context menus in the editor.
Plugin for adding custom context menus in the editor.
EditorContextMenuPlugin allows for the addition of custom options in the editor's context menu. Register them with EditorPlugin.AddContextMenuPlugin.
See EditorContextMenuPlugin.ContextMenuSlot for the list of available areas where context menu plugins are supported.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
EditorContextMenuPluginConstructor
public EditorContextMenuPlugin();Methods6
AddContextMenuItemvoid
public void AddContextMenuItem(string name, Callable callback, Texture2D icon = null);Add custom option to the context menu of the plugin's specified slot. callback should be a method that takes a single argument of type Reckfell.Collections.Dictionary. It will be called when the option is activated and the data received in the callback is the same as in EditorContextMenuPlugin._GetMenuOptions.
If you want to assign shortcut to the menu item, use EditorContextMenuPlugin.AddContextMenuItemFromShortcut instead.
| Name | Type | Default |
|---|---|---|
name | string | — |
callback | Callable | — |
icon | Texture2D | null |
AddContextMenuItemFromShortcutvoid
public void AddContextMenuItemFromShortcut(string name, Shortcut shortcut, Texture2D icon = null);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 EditorContextMenuPlugin.AddMenuShortcut.
| Name | Type | Default |
|---|---|---|
name | string | — |
shortcut | Shortcut | — |
icon | Texture2D | null |
AddContextSubmenuItemvoid
public void AddContextSubmenuItem(string name, PopupMenu menu, Texture2D icon = null);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.
| Name | Type | Default |
|---|---|---|
name | string | — |
menu | PopupMenu | — |
icon | Texture2D | null |
AddMenuShortcutvoid
public void AddMenuShortcut(Shortcut shortcut, Callable callback);Registers a shortcut associated with the plugin's context menu. This method should be called once (e.g. in the plugin's Object._init). callback will be called when user presses the specified shortcut while the menu's context is in effect (e.g. Content Browser is focused). Callback should take single data Reckfell.Collections.Dictionary, same as in EditorContextMenuPlugin.AddContextMenuItem.
| Name | Type | Default |
|---|---|---|
shortcut | Shortcut | — |
callback | Callable | — |
_GetMenuOptionsvoid
public virtual void _GetMenuOptions(Reckfell.Collections.Dictionary<StringName, Variant> data);Called when creating a context menu, custom options can be added by using the EditorContextMenuPlugin.AddContextMenuItem or EditorContextMenuPlugin.AddContextMenuItemFromShortcut functions. data contains the context data, which differs depending on the context menu slot. See the descriptions of EditorContextMenuPlugin.ContextMenuSlot for more information.
| Name | Type | Default |
|---|---|---|
data | Reckfell.Collections.Dictionary<StringName, Variant> | — |
_PopupMenuvoid · Deprecated
public virtual void _PopupMenu(string[] paths);Note: Implementing this method makes the shortcut callbacks receive legacy data (for compatibility reasons).
| Name | Type | Default |
|---|---|---|
paths | string[] | — |
EditorContextMenuPlugin.ContextMenuSlot
| Value | Description |
|---|---|
Filesystem = 1 | Context menu of Content Browser. The data |
FilesystemCreate = 3 | The "Create..." submenu of Content Browser's context menu, or the "New" section of the main context menu when empty space is clicked. The data |
InspectorProperty = 7 | Context menu of an editor property in the inspector. The data |
SceneTabs = 5 | Context menu of scene tabs. The data |
SceneTree = 0 | Context menu of Scene dock. The data |
ScriptEditor = 2 | Context menu of Script editor's script tabs and Shader editor's shader tabs. The data |
ScriptEditorCode = 4 | Context menu of Script editor's code editor. The data |
Slot2DEditor = 6 | Context menu of the 2D editor's viewport. The data |