diff --git a/doc/classes/EditorInterface.xml b/doc/classes/EditorInterface.xml
index 43059db8b2e..0304499a61d 100644
--- a/doc/classes/EditorInterface.xml
+++ b/doc/classes/EditorInterface.xml
@@ -301,6 +301,15 @@
See also [method Window.set_unparent_when_invisible].
+
+
+
+
+
+
+ Pops up an editor dialog for selecting a method from [param object]. The [param callback] must take a single argument of type [String] which will contain the name of the selected method or be empty if the dialog is canceled. If [param current_value] is provided, the method will be selected automatically in the method list, if it exists.
+
+
diff --git a/editor/editor_interface.cpp b/editor/editor_interface.cpp
index 264c80dcbf5..304b9d4b8cf 100644
--- a/editor/editor_interface.cpp
+++ b/editor/editor_interface.cpp
@@ -337,6 +337,19 @@ void EditorInterface::popup_property_selector(Object *p_object, const Callable &
property_selector->connect(SNAME("canceled"), canceled_callback, CONNECT_DEFERRED);
}
+void EditorInterface::popup_method_selector(Object *p_object, const Callable &p_callback, const String &p_current_value) {
+ if (!method_selector) {
+ method_selector = memnew(PropertySelector);
+ get_base_control()->add_child(method_selector);
+ }
+
+ method_selector->select_method_from_instance(p_object, p_current_value);
+
+ const Callable callback = callable_mp(this, &EditorInterface::_method_selected);
+ method_selector->connect(SNAME("selected"), callback.bind(p_callback), CONNECT_DEFERRED);
+ method_selector->connect(SNAME("canceled"), callback.bind(String(), p_callback), CONNECT_DEFERRED);
+}
+
void EditorInterface::popup_quick_open(const Callable &p_callback, const TypedArray &p_base_types) {
StringName required_type = SNAME("Resource");
Vector base_types;
@@ -372,6 +385,18 @@ void EditorInterface::_property_selection_canceled(const Callable &p_callback) {
_call_dialog_callback(p_callback, NodePath(), "property selection canceled");
}
+void EditorInterface::_method_selected(const String &p_method_name, const Callable &p_callback) {
+ const Callable callback = callable_mp(this, &EditorInterface::_method_selected);
+ method_selector->disconnect(SNAME("selected"), callback);
+ method_selector->disconnect(SNAME("canceled"), callback);
+
+ if (p_method_name.is_empty()) {
+ _call_dialog_callback(p_callback, p_method_name, "method selection canceled");
+ } else {
+ _call_dialog_callback(p_callback, p_method_name, "method selected");
+ }
+}
+
void EditorInterface::_quick_open(const String &p_file_path, const Callable &p_callback) {
EditorQuickOpenDialog *quick_open = EditorNode::get_singleton()->get_quick_open_dialog();
quick_open->disconnect(SNAME("canceled"), callable_mp(this, &EditorInterface::_quick_open));
@@ -593,6 +618,7 @@ void EditorInterface::_bind_methods() {
ClassDB::bind_method(D_METHOD("popup_node_selector", "callback", "valid_types", "current_value"), &EditorInterface::popup_node_selector, DEFVAL(TypedArray()), DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("popup_property_selector", "object", "callback", "type_filter", "current_value"), &EditorInterface::popup_property_selector, DEFVAL(PackedInt32Array()), DEFVAL(String()));
+ ClassDB::bind_method(D_METHOD("popup_method_selector", "object", "callback", "current_value"), &EditorInterface::popup_method_selector, DEFVAL(String()));
ClassDB::bind_method(D_METHOD("popup_quick_open", "callback", "base_types"), &EditorInterface::popup_quick_open, DEFVAL(TypedArray()));
// Editor docks.
diff --git a/editor/editor_interface.h b/editor/editor_interface.h
index 4877444dac4..c1032bf9b6b 100644
--- a/editor/editor_interface.h
+++ b/editor/editor_interface.h
@@ -66,12 +66,14 @@ class EditorInterface : public Object {
// Editor dialogs.
PropertySelector *property_selector = nullptr;
+ PropertySelector *method_selector = nullptr;
SceneTreeDialog *node_selector = nullptr;
void _node_selected(const NodePath &p_node_paths, const Callable &p_callback);
void _node_selection_canceled(const Callable &p_callback);
void _property_selected(const String &p_property_name, const Callable &p_callback);
void _property_selection_canceled(const Callable &p_callback);
+ void _method_selected(const String &p_property_name, const Callable &p_callback);
void _quick_open(const String &p_file_path, const Callable &p_callback);
void _call_dialog_callback(const Callable &p_callback, const Variant &p_selected, const String &p_context);
@@ -139,6 +141,7 @@ public:
void popup_node_selector(const Callable &p_callback, const TypedArray &p_valid_types = TypedArray(), Node *p_current_value = nullptr);
// Must use Vector because exposing Vector is not supported.
void popup_property_selector(Object *p_object, const Callable &p_callback, const PackedInt32Array &p_type_filter = PackedInt32Array(), const String &p_current_value = String());
+ void popup_method_selector(Object *p_object, const Callable &p_callback, const String &p_current_value = String());
void popup_quick_open(const Callable &p_callback, const TypedArray &p_base_types = TypedArray());
// Editor docks.