From c84e73bf92735f0f1ab30d4401db48945ead914b Mon Sep 17 00:00:00 2001 From: Marqus Date: Wed, 9 Oct 2019 17:41:49 +0200 Subject: Add shortcut Shift + F3 to search pervious in the built-in docs When using the built-in docs, Godot would not support the shortcut "Shift + F3" to search for the previous occurrence of the search entry text, thus causing an inconsistent behaviour when using shortcuts in the "ScriptEditor" compared to using them in the "ScriptTextEditor". The previous parameter of the function "EditorHelp::_search()" in the class "editor_help" seems to be unused, thus replaced with a bool representing to search for previous search entry text or not. By adding the shortcut to Godot's "ScriptEditor", this commit now improves Godot's consistensy when using shortcuts. Fixes #31147. Co-Authored-By: Oscar Ferm --- editor/editor_help.cpp | 11 +++++++---- editor/editor_help.h | 4 ++-- editor/plugins/script_editor_plugin.cpp | 4 ++++ editor/plugins/script_editor_plugin.h | 1 + 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 83434a6d9f..4a1e93eaad 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -72,9 +72,12 @@ void EditorHelp::_unhandled_key_input(const Ref &p_ev) { } } -void EditorHelp::_search(const String &) { +void EditorHelp::_search(bool p_search_previous) { - find_bar->search_next(); + if (p_search_previous) + find_bar->search_prev(); + else + find_bar->search_next(); } void EditorHelp::_class_list_select(const String &p_select) { @@ -1502,8 +1505,8 @@ String EditorHelp::get_class() { return edited_class; } -void EditorHelp::search_again() { - _search(prev_search); +void EditorHelp::search_again(bool p_search_previous) { + _search(p_search_previous); } int EditorHelp::get_scroll() const { diff --git a/editor/editor_help.h b/editor/editor_help.h index 1019cafffc..23a6e005a0 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -158,7 +158,7 @@ class EditorHelp : public VBoxContainer { void _update_doc(); void _request_help(const String &p_string); - void _search(const String &p_str); + void _search(bool p_search_previous = false); void _unhandled_key_input(const Ref &p_ev); @@ -179,7 +179,7 @@ public: void scroll_to_section(int p_section_index); void popup_search(); - void search_again(); + void search_again(bool p_search_previous = false); String get_class(); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 80b0f0738a..132a491fb3 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1325,6 +1325,9 @@ void ScriptEditor::_menu_option(int p_option) { case HELP_SEARCH_FIND_NEXT: { help->search_again(); } break; + case HELP_SEARCH_FIND_PREVIOUS: { + help->search_again(true); + } break; case FILE_CLOSE: { _close_current_tab(); } break; @@ -2827,6 +2830,7 @@ void ScriptEditor::_update_selected_editor_menu() { script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find", TTR("Find..."), KEY_MASK_CMD | KEY_F), HELP_SEARCH_FIND); script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_next", TTR("Find Next"), KEY_F3), HELP_SEARCH_FIND_NEXT); + script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT | KEY_F3), HELP_SEARCH_FIND_PREVIOUS); script_search_menu->get_popup()->add_separator(); script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_in_files", TTR("Find in Files"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F), SEARCH_IN_FILES); script_search_menu->show(); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 0c876108a5..8ff7a2222d 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -168,6 +168,7 @@ class ScriptEditor : public PanelContainer { REQUEST_DOCS, HELP_SEARCH_FIND, HELP_SEARCH_FIND_NEXT, + HELP_SEARCH_FIND_PREVIOUS, WINDOW_MOVE_UP, WINDOW_MOVE_DOWN, WINDOW_NEXT, -- cgit v1.2.3