Merge pull request #48605 from sent44/scripteditor_get_codeedit

Add `get_base_editor` to `ScriptEditorBase`
This commit is contained in:
Rémi Verschelde 2021-05-16 23:06:01 +02:00 committed by GitHub
commit 37c3b33253
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 29 additions and 0 deletions

View File

@ -18,6 +18,13 @@
Adds a [EditorSyntaxHighlighter] to the open script.
</description>
</method>
<method name="get_base_editor" qualifiers="const">
<return type="Control">
</return>
<description>
Returns the underlying [Control] used for editing scripts. This can be either [CodeEdit] (for text scripts) or [GraphEdit] (for visual scripts).
</description>
</method>
</methods>
<signals>
<signal name="edited_script_changed">

View File

@ -218,6 +218,8 @@ Ref<EditorSyntaxHighlighter> EditorPlainTextSyntaxHighlighter::_create() const {
/*** SCRIPT EDITOR ****/
void ScriptEditorBase::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_base_editor"), &ScriptEditorBase::get_base_editor);
ADD_SIGNAL(MethodInfo("name_changed"));
ADD_SIGNAL(MethodInfo("edited_script_changed"));
ADD_SIGNAL(MethodInfo("request_help", PropertyInfo(Variant::STRING, "topic")));

View File

@ -163,6 +163,8 @@ public:
virtual Control *get_edit_menu() = 0;
virtual void clear_edit_menu() = 0;
virtual Control *get_base_editor() const = 0;
virtual void validate() = 0;
ScriptEditorBase() {}

View File

@ -1402,6 +1402,10 @@ void ScriptTextEditor::set_tooltip_request_func(String p_method, Object *p_obj)
void ScriptTextEditor::set_debugger_active(bool p_active) {
}
Control *ScriptTextEditor::get_base_editor() const {
return code_editor->get_text_editor();
}
Variant ScriptTextEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
return Variant();
}

View File

@ -233,6 +233,8 @@ public:
virtual void clear_edit_menu() override;
static void register_editor();
virtual Control *get_base_editor() const override;
virtual void validate() override;
ScriptTextEditor();

View File

@ -171,6 +171,10 @@ void TextEditor::add_callback(const String &p_function, PackedStringArray p_args
void TextEditor::set_debugger_active(bool p_active) {
}
Control *TextEditor::get_base_editor() const {
return code_editor->get_text_editor();
}
Array TextEditor::get_breakpoints() {
return Array();
}

View File

@ -142,6 +142,8 @@ public:
virtual void validate() override;
virtual Control *get_base_editor() const override;
static void register_editor();
TextEditor();

View File

@ -2710,6 +2710,10 @@ void VisualScriptEditor::set_debugger_active(bool p_active) {
}
}
Control *VisualScriptEditor::get_base_editor() const {
return graph;
}
void VisualScriptEditor::set_tooltip_request_func(String p_method, Object *p_obj) {
}

View File

@ -320,6 +320,8 @@ public:
virtual bool can_lose_focus_on_node_selection() override { return false; }
virtual void validate() override;
virtual Control *get_base_editor() const override;
static void register_editor();
static void free_clipboard();