From f3df9c24346e6d37b32e0f215827fdbd3114356c Mon Sep 17 00:00:00 2001 From: arkology <43543909+arkology@users.noreply.github.com> Date: Sat, 7 Feb 2026 20:39:25 +0300 Subject: [PATCH] Convert "Line and column numbers" label to button --- editor/gui/code_editor.cpp | 30 ++++++++++++++++++---------- editor/gui/code_editor.h | 4 +++- editor/script/script_editor_base.cpp | 1 + editor/shader/text_shader_editor.cpp | 1 + 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/editor/gui/code_editor.cpp b/editor/gui/code_editor.cpp index e56bd0a04c..6b3bd87b1f 100644 --- a/editor/gui/code_editor.cpp +++ b/editor/gui/code_editor.cpp @@ -95,6 +95,7 @@ void GotoLinePopup::_notification(int p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { if (!is_visible()) { text_editor->set_preview_navigation_change(false); + text_editor->get_text_editor()->grab_focus(); } } break; } @@ -993,7 +994,7 @@ void CodeTextEditor::_line_col_changed() { sb.append(" : "); sb.append(itos(positional_column + 1).lpad(3)); - line_and_col_txt->set_text(sb.as_string()); + line_and_col_button->set_text(sb.as_string()); if (find_replace_bar) { if (!find_replace_bar->line_col_changed_for_result) { @@ -1855,11 +1856,16 @@ float CodeTextEditor::get_zoom_factor() { return zoom_factor; } +void CodeTextEditor::_show_goto_popup_request() { + emit_signal("show_goto_popup"); +} + void CodeTextEditor::_bind_methods() { ADD_SIGNAL(MethodInfo("validate_script")); ADD_SIGNAL(MethodInfo("load_theme_settings")); ADD_SIGNAL(MethodInfo("show_errors_panel")); ADD_SIGNAL(MethodInfo("show_warnings_panel")); + ADD_SIGNAL(MethodInfo("show_goto_popup")); ADD_SIGNAL(MethodInfo("navigation_preview_ended")); ADD_SIGNAL(MethodInfo("zoomed", PropertyInfo(Variant::FLOAT, "p_zoom_factor"))); } @@ -1982,16 +1988,18 @@ CodeTextEditor::CodeTextEditor() { status_bar->add_child(memnew(VSeparator)); - // Line and column - line_and_col_txt = memnew(Label); - status_bar->add_child(line_and_col_txt); - line_and_col_txt->set_v_size_flags(SIZE_EXPAND | SIZE_SHRINK_CENTER); - line_and_col_txt->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); - line_and_col_txt->set_tooltip_auto_translate_mode(AUTO_TRANSLATE_MODE_ALWAYS); - line_and_col_txt->set_tooltip_text(TTRC("Line and column numbers.")); - line_and_col_txt->set_accessibility_name(TTRC("Line and column numbers.")); - line_and_col_txt->set_focus_mode(FOCUS_ACCESSIBILITY); - line_and_col_txt->set_mouse_filter(MOUSE_FILTER_STOP); + // Line and column. + line_and_col_button = memnew(Button); + line_and_col_button->set_theme_type_variation("FlatMenuButton"); + line_and_col_button->set_v_size_flags(SIZE_EXPAND | SIZE_SHRINK_CENTER); + line_and_col_button->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); + line_and_col_button->set_tooltip_auto_translate_mode(AUTO_TRANSLATE_MODE_ALWAYS); + line_and_col_button->set_tooltip_text(TTRC("Line and column numbers.")); + line_and_col_button->set_accessibility_name(TTRC("Line and column numbers.")); + line_and_col_button->connect(SceneStringName(pressed), callable_mp(this, &CodeTextEditor::_show_goto_popup_request)); + line_and_col_button->set_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_line")); + line_and_col_button->set_shortcut_context(this); + status_bar->add_child(line_and_col_button); status_bar->add_child(memnew(VSeparator)); diff --git a/editor/gui/code_editor.h b/editor/gui/code_editor.h index ec7024a2b4..7f99820216 100644 --- a/editor/gui/code_editor.h +++ b/editor/gui/code_editor.h @@ -169,7 +169,7 @@ class CodeTextEditor : public VBoxContainer { Button *warning_button = nullptr; MenuButton *zoom_button = nullptr; - Label *line_and_col_txt = nullptr; + Button *line_and_col_button = nullptr; Label *indentation_txt = nullptr; Timer *idle = nullptr; @@ -209,6 +209,8 @@ class CodeTextEditor : public VBoxContainer { void _zoom_out(); void _zoom_to(float p_zoom_factor); + void _show_goto_popup_request(); + void _update_error_content_height(); void _error_button_pressed(); diff --git a/editor/script/script_editor_base.cpp b/editor/script/script_editor_base.cpp index 5a8403036b..00623f193a 100644 --- a/editor/script/script_editor_base.cpp +++ b/editor/script/script_editor_base.cpp @@ -639,6 +639,7 @@ TextEditorBase::TextEditorBase() { code_editor->get_text_editor()->connect(SceneStringName(gui_input), callable_mp(this, &TextEditorBase::_text_edit_gui_input)); code_editor->connect("validate_script", callable_mp(this, &TextEditorBase::_validate_script)); code_editor->connect("load_theme_settings", callable_mp(this, &TextEditorBase::_load_theme_settings)); + code_editor->connect("show_goto_popup", callable_mp(this, &TextEditorBase::_edit_option).bind(SEARCH_GOTO_LINE)); context_menu = memnew(PopupMenu); context_menu->connect(SceneStringName(id_pressed), callable_mp(this, &TextEditorBase::_edit_option)); diff --git a/editor/shader/text_shader_editor.cpp b/editor/shader/text_shader_editor.cpp index 41e9d7a87d..3ca3423ea9 100644 --- a/editor/shader/text_shader_editor.cpp +++ b/editor/shader/text_shader_editor.cpp @@ -1307,6 +1307,7 @@ TextShaderEditor::TextShaderEditor() { goto_line_popup = memnew(GotoLinePopup); add_child(goto_line_popup); + code_editor->connect("show_goto_popup", callable_mp(this, &TextShaderEditor::_menu_option).bind(SEARCH_GOTO_LINE)); disk_changed = memnew(ConfirmationDialog);