Godot Version
v4.4.1.stable.official [49a5bc7b6]
Question
For the plugin I am making now, I need to add an option to the FileSystem’s right-click context menu. After I successfully adding my option as the method provided by this GitHub comment, I try to move my newly added option to the desired place, but I failed to do that.
I have tried move_child
, but that does not seems to work, the item seems to be internal.
Could I ask if there is a way of re-ordering the item in the PopupMenu
?
Code example (part copied from the GitHub comment mentioned above):
@tool
extends EditorScript
static func add_custom(popup: PopupMenu):
# All other item are added, so this item will be at the last.
popup.add_item("Test", 10000)
# How could I move it up ?
func _run() -> void:
var fs = EditorInterface.get_base_control().find_child("*FileSystem*", true, false)
var popup: PopupMenu = fs.get_child(2)
popup.about_to_popup.connect(add_custom.bind(popup), CONNECT_DEFERRED)