MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _add_callback

Method _add_callback

editor/script/script_editor_plugin.cpp:3015–3052  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3013}
3014
3015void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const PackedStringArray &p_args) {
3016 ERR_FAIL_NULL(p_obj);
3017 Ref<Script> scr = p_obj->get_script();
3018 ERR_FAIL_COND(scr.is_null());
3019
3020 if (!scr->get_language()->can_make_function()) {
3021 return;
3022 }
3023
3024 EditorNode::get_singleton()->push_item(scr.ptr());
3025
3026 for (int i = 0; i < tab_container->get_tab_count(); i++) {
3027 ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
3028 if (!se) {
3029 continue;
3030 }
3031 if (se->get_edited_resource() != scr) {
3032 continue;
3033 }
3034
3035 se->add_callback(p_function, p_args);
3036
3037 _go_to_tab(i);
3038
3039 script_list->select(script_list->find_metadata(i));
3040
3041 // Save the current script so the changes can be picked up by an external editor.
3042 if (!scr.ptr()->is_built_in()) { // But only if it's not built-in script.
3043 save_current_script();
3044 }
3045
3046 break;
3047 }
3048
3049 // Move back to the previously edited node to reselect it in the Inspector and the NodeDock.
3050 // We assume that the previous item is the node on which the callbacks were added.
3051 EditorNode::get_singleton()->edit_previous_item();
3052}
3053
3054void ScriptEditor::_save_editor_state(ScriptEditorBase *p_editor) {
3055 if (restoring_layout) {

Callers

nothing calls this directly

Calls 14

push_itemMethod · 0.80
get_tab_controlMethod · 0.80
find_metadataMethod · 0.80
is_built_inMethod · 0.80
edit_previous_itemMethod · 0.80
get_scriptMethod · 0.45
is_nullMethod · 0.45
can_make_functionMethod · 0.45
get_languageMethod · 0.45
ptrMethod · 0.45
get_tab_countMethod · 0.45
get_edited_resourceMethod · 0.45

Tested by

no test coverage detected