Skip to content

Commit

Permalink
Merge pull request #82283 from YeldhamDev/focus_that_search_bar!
Browse files Browse the repository at this point in the history
Make the search bars in the "Project Settings" dialog grab focus when they appear
  • Loading branch information
akien-mga committed Jan 4, 2024
2 parents c772a5b + c7d0565 commit ad3e5a9
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion editor/action_map_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ ActionMapEditor::ActionMapEditor() {

action_list_search = memnew(LineEdit);
action_list_search->set_h_size_flags(Control::SIZE_EXPAND_FILL);
action_list_search->set_placeholder(TTR("Filter by name..."));
action_list_search->set_placeholder(TTR("Filter by Name"));
action_list_search->set_clear_button_enabled(true);
action_list_search->connect("text_changed", callable_mp(this, &ActionMapEditor::_search_term_updated));
top_hbox->add_child(action_list_search);
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_build_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ EditorBuildProfileManager::EditorBuildProfileManager() {
export_profile->set_access(EditorFileDialog::ACCESS_FILESYSTEM);

force_detect_classes = memnew(LineEdit);
main_vbc->add_margin_child(TTR("Forced classes on detect:"), force_detect_classes);
main_vbc->add_margin_child(TTR("Forced Classes on Detect:"), force_detect_classes);
force_detect_classes->connect("text_changed", callable_mp(this, &EditorBuildProfileManager::_force_detect_classes_changed));

set_title(TTR("Edit Build Configuration Profile"));
Expand Down
5 changes: 1 addition & 4 deletions editor/editor_settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ void EditorSettingsDialog::popup_edit_settings() {
inspector->edit(EditorSettings::get_singleton());
inspector->get_inspector()->update_tree();

search_box->select_all();
search_box->grab_focus();

_update_shortcuts();
set_process_shortcut_input(true);

Expand Down Expand Up @@ -762,7 +759,7 @@ EditorSettingsDialog::EditorSettingsDialog() {
tab_shortcuts->add_child(top_hbox);

shortcut_search_box = memnew(LineEdit);
shortcut_search_box->set_placeholder(TTR("Filter by name..."));
shortcut_search_box->set_placeholder(TTR("Filter by Name"));
shortcut_search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
top_hbox->add_child(shortcut_search_box);
shortcut_search_box->connect("text_changed", callable_mp(this, &EditorSettingsDialog::_filter_shortcuts));
Expand Down
6 changes: 3 additions & 3 deletions editor/event_listener_line_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ void EventListenerLineEdit::_on_text_changed(const String &p_text) {
}

void EventListenerLineEdit::_on_focus() {
set_placeholder(TTR("Listening for input..."));
set_placeholder(TTR("Listening for Input"));
}

void EventListenerLineEdit::_on_unfocus() {
ignore_next_event = true;
set_placeholder(TTR("Filter by event..."));
set_placeholder(TTR("Filter by Event"));
}

Ref<InputEvent> EventListenerLineEdit::get_event() const {
Expand Down Expand Up @@ -227,5 +227,5 @@ void EventListenerLineEdit::_bind_methods() {

EventListenerLineEdit::EventListenerLineEdit() {
set_caret_blink_enabled(false);
set_placeholder(TTR("Filter by event..."));
set_placeholder(TTR("Filter by Event"));
}
25 changes: 23 additions & 2 deletions editor/project_settings_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions editor/project_settings_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class ProjectSettingsEditor : public AcceptDialog {
void _add_setting();
void _delete_setting();

void _tabs_tab_changed(int p_tab);
void _focus_current_search_box();

void _editor_restart_request();
void _editor_restart();
void _editor_restart_close();
Expand Down

0 comments on commit ad3e5a9

Please sign in to comment.