1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

Merge pull request #82283 from YeldhamDev/focus_that_search_bar!

Make the search bars in the "Project Settings" dialog grab focus when they appear
This commit is contained in:
Rémi Verschelde
2024-01-04 16:38:52 +01:00
6 changed files with 32 additions and 11 deletions

View File

@@ -70,6 +70,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() {
@@ -255,8 +257,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;
}
@@ -328,6 +329,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();
@@ -598,6 +618,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);