diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-04-04 22:47:44 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-04-05 01:45:39 +0200 |
commit | d89d00ac7ee50c911b9aa1b5cc6b04b1c54ca761 (patch) | |
tree | 72fff7b58eb4e7c9fbf80d9336f8b1b5c45b8451 /editor/project_manager.cpp | |
parent | a864a703ee27065795c6297aaeb72ed753d0f279 (diff) |
Automatically focus the Search field when displaying asset library
- Focus the project search box when switching from the Templates tab
back to the Projects tab in the project manager.
- Add a context-specific placeholder for the asset library search box.
- Rename "Search" project filter box placeholder to the more
descriptive "Filter projects". When performing a search on an
existing selection, "Filter" is more accurate than "Search".
Diffstat (limited to 'editor/project_manager.cpp')
-rw-r--r-- | editor/project_manager.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index eda9499783..1f5c14b637 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -2331,6 +2331,17 @@ void ProjectManager::_on_order_option_changed(int p_idx) { } } +void ProjectManager::_on_tab_changed(int p_tab) { + if (p_tab == 0) { // Projects + // Automatically grab focus when the user moves from the Templates tab + // back to the Projects tab. + search_box->grab_focus(); + } + + // The Templates tab's search field is focused on display in the asset + // library editor plugin code. +} + void ProjectManager::_on_search_term_changed(const String &p_term) { _project_list->set_search_term(p_term); _project_list->sort_projects(); @@ -2456,6 +2467,7 @@ ProjectManager::ProjectManager() { center_box->add_child(tabs); tabs->set_anchors_and_offsets_preset(Control::PRESET_WIDE); tabs->set_tab_align(TabContainer::ALIGN_LEFT); + tabs->connect("tab_changed", callable_mp(this, &ProjectManager::_on_tab_changed)); HBoxContainer *projects_hb = memnew(HBoxContainer); projects_hb->set_name(TTR("Projects")); @@ -2472,8 +2484,8 @@ ProjectManager::ProjectManager() { search_tree_vb->add_child(hb); search_box = memnew(LineEdit); - search_box->set_placeholder(TTR("Search")); - search_box->set_tooltip(TTR("The search box filters projects by name and last path component.\nTo filter projects by name and full path, the query must contain at least one `/` character.")); + search_box->set_placeholder(TTR("Filter projects")); + search_box->set_tooltip(TTR("This field filters projects by name and last path component.\nTo filter projects by name and full path, the query must contain at least one `/` character.")); search_box->connect("text_changed", callable_mp(this, &ProjectManager::_on_search_term_changed)); search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); hb->add_child(search_box); |