Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability for plugins to add entry under right mouse click context menu #6128

Closed
Tracked by #6276
kubecz3k opened this issue Aug 12, 2016 · 6 comments
Closed
Tracked by #6276

Comments

@kubecz3k
Copy link
Contributor

Operating system or device - Godot version:

Issue description (what happened, and what was expected):
Yesterday I wrote a plugin which potentially solves #4584 #4584 (it allows you to extend scenes easily).
The problem is there is no way to add an entry to right click mouse button context menu, so I needed to put new button near the editor 'settings' button, which is not elegant and take space all the time. Besides I can imagine there will be more plugins which allows to perform operations on nodes selected in scene tree tab...

In context menu I think there should be subcategory for each plugin which would automatically unfold when mouse cursor is near:
subcategory

Steps to reproduce:

Link to minimal example project (optional but very welcome):

@ghost
Copy link

ghost commented Aug 14, 2016

I was thinking on something like this(I proposed it on #4276, for menu buttons) which is like i implemented on #6065, but with a new class.
I don't like the idea of creating a submenu for each plugin, it's strange have a submenu for a plugin that only needs one item. For this i prefer to manually add the items to the menu(The developer can choose to add a single item or a submenu) using exposed functions in the EditorPlugin:

enum ContextMenu {
    CONTEXT_MENU_SCENE_DOCK,
    CONTEXT_MENU_FILESYSTEM_DOCK
    // And possibly others
};

void add_item_to_context_menu(ContextMenu menu, String name, Object *handler, String callback, Variant ud);
// And possibly other functions to add a item with a icon or shortcut.
void add_submenu_to_context_menu(ContextMenu menu, String name, PopupMenu submenu);
void remove_item_from_context_menu(ContextMenu menu, String name);

The way of where the menu will display the plugin item can be:

  1. The items are always added to the bottom of menu.
  2. Every item needs to have a category, every group of items between separators is a category, the developer will pass the items category with category/My Item Text or an additional parameter to in the function. New categories are added to the bottom of menu. This can be quite problematic to implement because the contextual menu of scene and filesystem docks are recreated before it's displayed, and all possible position needs to be documented, but this will create intuitive and elegant entries.
  3. Every contextual menu will have a submenu for plugins items, and it'll work the same way of the "Tools" menu API(Add a API to add/remove items to the "Tools" menu #6065), this will prevent the contextual menus from getting too crowded.

@27thLiz
Copy link
Contributor

27thLiz commented Jun 8, 2017

I suggest to also add an optional callback that allows for overriding whether or not the item should be instanced when recreating the context menu.
So the above example would change to:

void add_item_to_context_menu(ContextMenu menu, String name, Object *handler, String callback, Variant ud, String can_instance_callback="");

This is useful for context-sensitive context menus (wow, what a sentence :p).
Say you have an EditorPlugin that operates on TileMap nodes, you wouldn't want the menu item to appear when right clicking on another node type.

@reduz
Copy link
Member

reduz commented Aug 5, 2017

kicking to 3.1

@reduz reduz modified the milestones: 3.1, 3.0 Aug 5, 2017
@bfloch
Copy link
Contributor

bfloch commented Jan 22, 2018

I could use this for #15928 - A way to add a custom tools to scene_tree_dock context menu.

As is, the proposal seems to miss the ability to assign shortcuts. Any thoughts on this?

@akien-mga
Copy link
Member

Moving to the next milestone as 3.1 is now feature frozen.

@akien-mga akien-mga modified the milestones: 3.1, 3.2 Sep 15, 2018
@akien-mga akien-mga removed this from the 3.2 milestone Nov 11, 2019
@akien-mga
Copy link
Member

Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.

The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.

If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants