-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
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
Add support for custom items to editor right-click context menus #94582
Add support for custom items to editor right-click context menus #94582
Conversation
080aabd
to
19076fa
Compare
So I tested this and it works, but the API is super weird. I think instead of Instead of keeping an array of plugins per slot, I think it can be a single LocalVector. When opening menu, go through the vector and check the plugin slot. If the slot matches, call To make your life easier, this can be handled with internal methods: Feel free to ask if something is not clear. You can also join the developer chat. |
19076fa
to
8b925a4
Compare
Based on the recommendations, the final API has been adjusted; extends EditorContextMenuPlugin
const PLUG = preload("res://addons/csv-update/plug.svg")
func _popup_menu(paths: PackedStringArray) -> bool:
## The return result will determine whether to display the added options.
add_context_menu_item("File Custom options", handle, PLUG)
return true
func handle(paths):
print("file context item handle:", paths)
|
8b925a4
to
8233b0b
Compare
8233b0b
to
56dce9a
Compare
This comment was marked as resolved.
This comment was marked as resolved.
@@ -101,6 +102,13 @@ class EditorPlugin : public Node { | |||
AFTER_GUI_INPUT_CUSTOM, | |||
}; | |||
|
|||
enum ContextMenuSlot { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be moved to EditorContextMenuPlugin instead.
EditorPlugin has similar enums, but they don't have a dedicated class.
Looking at all the new methods in EditorData, I think they can be moved to some new class called EditorContextMenuManager 🤔 Like EditorInspector manages inspector plugins or 3D editor manages gizmo plugins etc. |
8d008a8
to
706bb90
Compare
244a586
to
6976f39
Compare
<method name="remove_context_menu_plugin"> | ||
<return type="void" /> | ||
<param index="0" name="slot" type="int" enum="EditorPlugin.ContextMenuSlot" /> | ||
<param index="1" name="plugin" type="EditorContextMenuPlugin" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think functionality-wise it's ok now and the implementation is good enough. It can be merged once you address some last comments.
6976f39
to
8916bf0
Compare
8916bf0
to
f0efc90
Compare
f0efc90
to
98d3d1b
Compare
Amended the commit message to match our preferred style for clarity. |
98d3d1b
to
6b2348a
Compare
Oh, what have I done? I thought I was just supposed to modify the commit message. Did my resubmission break anything? |
You fixed the message but it had already been fixed, and your branch was behind this one so you pulled it back to an earlier version |
Will my new force push affect this modification? Do I need to correct this error, or can I leave it as is? I'm not sure how to handle the pull request in this situation. |
You can leave it, I updated the PR message to match, but it's good in the future to pay attention to what happens in your PR to avoid undoing or redoing things |
My bad, I should have been more explicit that I did the action myself, and wasn't asking for you to do it :) |
Thanks! And congrats for your first merged Godot contribution 🎉 |
Add right-click menu plugin functionality to implement this proposal
Currently, I am only working on 3.x, but in order to incorporate this feature, this is a feature version of 4.x. The difference compared to 3.x is that additional submenu options have been added (currently only expanding the create new option for filesystem).
Please refer to the 3.x submission for a more detailed explanation here