Add methods to add submenus without using names #85477
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Inspired by #84668
This PR adds
add_direct_submenu_item()
and related methods. It takes a PopupMenu directly and does not rely on its name. Also automatically adds the menu as a child if it doesn't have a parent. Refactored PopupMenu internals to not use submenu names anywhere, they are only kept for compatibility. The old methods are now deprecated.There is some
global_menu_add_submenu_item()
method in DisplayServer, I did not touch it. I also changed editor usages to the new methods (except one case in AnimationNodeStateMachineEditor) and removed menu names, because they are no longer needed (this technically reverts #84617).Note that when using the old methods, they are now required to have the submenu already added as a child (it allows to call the new method and simplify the code). This was actually documented, but wasn't enforced.
The new methods might need some testing. I did check if editor works correctly and tested some internal popups, but did not test the methods extensively (especially together with the old methods).
EDIT:
Fixes #84692