diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-02-12 23:18:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-12 23:18:43 +0100 |
commit | 35d8d86845650d0e996b35ae98263310cd9f5499 (patch) | |
tree | 4f6b06c3582f0afb5de1a88f3660954f517d086a | |
parent | 0203b34c7a67c18400dbb18ecd61bcc73b395ee3 (diff) | |
parent | e5657a4fbfdbad4b6c9d50946364ef4a869790d6 (diff) |
Merge pull request #58026 from jmb462/fix-visual-script-rename-function
Fix renaming function dialog in VisualScript does not work correctly
-rw-r--r-- | modules/visual_script/editor/visual_script_editor.cpp | 10 | ||||
-rw-r--r-- | modules/visual_script/editor/visual_script_editor.h | 1 |
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(); |