1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-22 15:06:45 +00:00

Make the search bars in the "Project Settings" dialog grab focus when they appear

This commit is contained in:
Michael Alexsander
2023-09-25 01:09:29 -03:00
parent df0a822323
commit c7d0565681
6 changed files with 32 additions and 11 deletions

View File

@@ -68,6 +68,8 @@ void ProjectSettingsEditor::popup_project_settings(bool p_clear_filter) {
if (p_clear_filter) {
search_box->clear();
}
_focus_current_search_box();
}
void ProjectSettingsEditor::queue_save() {
@@ -253,8 +255,7 @@ void ProjectSettingsEditor::shortcut_input(const Ref<InputEvent> &p_event) {
}
if (k->is_match(InputEventKey::create_reference(KeyModifierMask::CMD_OR_CTRL | Key::F))) {
search_box->grab_focus();
search_box->select_all();
_focus_current_search_box();
handled = true;
}
@@ -326,6 +327,25 @@ void ProjectSettingsEditor::_add_feature_overrides() {
}
}
void ProjectSettingsEditor::_tabs_tab_changed(int p_tab) {
_focus_current_search_box();
}
void ProjectSettingsEditor::_focus_current_search_box() {
Control *tab = tab_container->get_current_tab_control();
LineEdit *current_search_box = nullptr;
if (tab == general_editor) {
current_search_box = search_box;
} else if (tab == action_map_editor) {
current_search_box = action_map_editor->get_search_box();
}
if (current_search_box) {
current_search_box->grab_focus();
current_search_box->select_all();
}
}
void ProjectSettingsEditor::_editor_restart() {
ProjectSettings::get_singleton()->save();
EditorNode::get_singleton()->save_all_scenes();
@@ -596,6 +616,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
tab_container = memnew(TabContainer);
tab_container->set_use_hidden_tabs_for_min_size(true);
tab_container->set_theme_type_variation("TabContainerOdd");
tab_container->connect("tab_changed", callable_mp(this, &ProjectSettingsEditor::_tabs_tab_changed));
add_child(tab_container);
general_editor = memnew(VBoxContainer);