diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-05-15 09:17:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-15 09:17:30 +0200 |
commit | df2caeb1b63322d5307c381be8cbe2b2cba3afc0 (patch) | |
tree | e3c8a3d7d4269f4d555d0bc346dadf508c265879 | |
parent | 6054febddea116a170205547e97a00744ce2801a (diff) | |
parent | 22e2e4334ef4c2e0b085fafe74f899e52d1577d4 (diff) |
Merge pull request #48707 from foxydevloper/filesystem_search_shortcut
Make shortcut focus searchbar in filesystem dock
-rw-r--r-- | editor/filesystem_dock.cpp | 18 | ||||
-rw-r--r-- | editor/filesystem_dock.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 6cd45fdf97..7ecfc5d520 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1986,6 +1986,20 @@ void FileSystemDock::_resource_created() { editor->save_resource_as(RES(r), fpath); } +void FileSystemDock::_focus_current_search_box() { + LineEdit *current_search_box = nullptr; + if (display_mode == DISPLAY_MODE_TREE_ONLY) { + current_search_box = tree_search_box; + } else if (display_mode == DISPLAY_MODE_SPLIT) { + current_search_box = file_list_search_box; + } + + if (current_search_box) { + current_search_box->grab_focus(); + current_search_box->select_all(); + } +} + void FileSystemDock::_search_changed(const String &p_text, const Control *p_from) { if (searched_string.length() == 0) { // Register the uncollapsed paths before they change. @@ -2576,6 +2590,8 @@ void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) { _tree_rmb_option(FILE_REMOVE); } else if (ED_IS_SHORTCUT("filesystem_dock/rename", p_event)) { _tree_rmb_option(FILE_RENAME); + } else if (ED_IS_SHORTCUT("editor/open_search", p_event)) { + _focus_current_search_box(); } else { return; } @@ -2595,6 +2611,8 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) { _file_list_rmb_option(FILE_REMOVE); } else if (ED_IS_SHORTCUT("filesystem_dock/rename", p_event)) { _file_list_rmb_option(FILE_RENAME); + } else if (ED_IS_SHORTCUT("editor/open_search", p_event)) { + _focus_current_search_box(); } else { return; } diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 39dc4784b8..8783c402cd 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -253,6 +253,7 @@ private: void _toggle_split_mode(bool p_active); + void _focus_current_search_box(); void _search_changed(const String &p_text, const Control *p_from); MenuButton *_create_file_menu_button(); |