summaryrefslogtreecommitdiff
path: root/modules/visual_script
diff options
context:
space:
mode:
authorjmb462 <jmb462@gmail.com>2022-02-12 21:28:28 +0100
committerjmb462 <jmb462@gmail.com>2022-02-12 21:28:28 +0100
commite5657a4fbfdbad4b6c9d50946364ef4a869790d6 (patch)
tree90f39f7dbebb97237f7f4f8ef7384192053bc931 /modules/visual_script
parentd3a6b6daaab4c8dfb7bdf35cc2fe2145ae6c22a1 (diff)
Fix renaming function dialog in VisualScript does not work correctly
Diffstat (limited to 'modules/visual_script')
-rw-r--r--modules/visual_script/editor/visual_script_editor.cpp10
-rw-r--r--modules/visual_script/editor/visual_script_editor.h1
2 files changed, 10 insertions, 1 deletions
diff --git a/modules/visual_script/editor/visual_script_editor.cpp b/modules/visual_script/editor/visual_script_editor.cpp
index 5ea8eaff00..9433f3dba2 100644
--- a/modules/visual_script/editor/visual_script_editor.cpp
+++ b/modules/visual_script/editor/visual_script_editor.cpp
@@ -1510,6 +1510,7 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
function_name_edit->popup();
function_name_box->set_text(selected);
function_name_box->select_all();
+ function_name_box->grab_focus();
}
}
@@ -2098,11 +2099,15 @@ void VisualScriptEditor::_fn_name_box_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> key = p_event;
if (key.is_valid() && key->is_pressed() && key->get_keycode() == Key::ENTER) {
function_name_edit->hide();
- _rename_function(selected, function_name_box->get_text());
+ _on_fn_name_box_confirmed();
function_name_box->clear();
}
}
+void VisualScriptEditor::_on_fn_name_box_confirmed() {
+ _rename_function(selected, function_name_box->get_text());
+}
+
Variant VisualScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
if (p_from == members) {
TreeItem *it = members->get_item_at_position(p_point);
@@ -4415,6 +4420,7 @@ void VisualScriptEditor::_member_option(int p_option) {
function_name_edit->popup();
function_name_box->set_text(selected);
function_name_box->select_all();
+ function_name_box->grab_focus();
}
} break;
case MEMBER_VARIABLE: {
@@ -4545,9 +4551,11 @@ VisualScriptEditor::VisualScriptEditor() {
member_popup->connect("id_pressed", callable_mp(this, &VisualScriptEditor::_member_option));
function_name_edit = memnew(AcceptDialog);
+ function_name_edit->set_title(TTR("Rename Function"));
function_name_box = memnew(LineEdit);
function_name_edit->add_child(function_name_box);
function_name_box->connect("gui_input", callable_mp(this, &VisualScriptEditor::_fn_name_box_input));
+ function_name_edit->get_ok_button()->connect("pressed", callable_mp(this, &VisualScriptEditor::_on_fn_name_box_confirmed));
function_name_box->set_expand_to_text_length_enabled(true);
add_child(function_name_edit);
diff --git a/modules/visual_script/editor/visual_script_editor.h b/modules/visual_script/editor/visual_script_editor.h
index b01732b2fd..e178f5cf72 100644
--- a/modules/visual_script/editor/visual_script_editor.h
+++ b/modules/visual_script/editor/visual_script_editor.h
@@ -247,6 +247,7 @@ class VisualScriptEditor : public ScriptEditorBase {
void _graph_gui_input(const Ref<InputEvent> &p_event);
void _members_gui_input(const Ref<InputEvent> &p_event);
void _fn_name_box_input(const Ref<InputEvent> &p_event);
+ void _on_fn_name_box_confirmed();
void _rename_function(const String &p_name, const String &p_new_name);
void _create_function_dialog();