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/plugins/asset_library_editor_plugin.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/plugins/asset_library_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 1345adc8ee..904517b119 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -557,8 +557,15 @@ void EditorAssetLibrary::_notification(int p_what) { error_label->raise(); } break; case NOTIFICATION_VISIBILITY_CHANGED: { - if (is_visible() && initial_loading) { - _repository_changed(0); // Update when shown for the first time. + if (is_visible()) { + // Focus the search box automatically when switching to the Templates tab (in the Project Manager) + // or switching to the AssetLib tab (in the editor). + // The Project Manager's project filter box is automatically focused in the project manager code. + filter->grab_focus(); + + if (initial_loading) { + _repository_changed(0); // Update when shown for the first time. + } } } break; case NOTIFICATION_PROCESS: { @@ -1332,6 +1339,11 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { library_main->add_theme_constant_override("separation", 10 * EDSCALE); filter = memnew(LineEdit); + if (templates_only) { + filter->set_placeholder(TTR("Search templates, projects, and demos")); + } else { + filter->set_placeholder(TTR("Search assets (excluding templates, projects, and demos)")); + } search_hb->add_child(filter); filter->set_h_size_flags(Control::SIZE_EXPAND_FILL); filter->connect("text_changed", callable_mp(this, &EditorAssetLibrary::_search_text_changed)); |