Add Ctrl + L / Cmd + Shift + G shortcut to focus path bar in FileDialog

This also tweaks EditorFileDialog to use the same shortcut,
while making it select the path text after focusing
(like in most file managers).

Ctrl + L / Cmd + Shift + G can also now be used to focus on the
property name in the project settings editor, as well in the
Input Map, Autoload, Shader Globals and Global Groups tabs.
This commit is contained in:
Hugo Locurcio 2023-08-30 20:11:21 +02:00
parent 01dc5c5b58
commit 4f8d7cae26
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
14 changed files with 84 additions and 2 deletions

View file

@ -256,11 +256,16 @@ void ProjectSettingsEditor::shortcut_input(const Ref<InputEvent> &p_event) {
handled = true;
}
if (k->is_match(InputEventKey::create_reference(KeyModifierMask::CMD_OR_CTRL | Key::F))) {
if (ED_IS_SHORTCUT("editor/open_search", p_event)) {
_focus_current_search_box();
handled = true;
}
if (ED_IS_SHORTCUT("file_dialog/focus_path", p_event)) {
_focus_current_path_box();
handled = true;
}
if (handled) {
set_input_as_handled();
}
@ -347,6 +352,27 @@ void ProjectSettingsEditor::_focus_current_search_box() {
}
}
void ProjectSettingsEditor::_focus_current_path_box() {
Control *tab = tab_container->get_current_tab_control();
LineEdit *current_path_box = nullptr;
if (tab == general_editor) {
current_path_box = property_box;
} else if (tab == action_map_editor) {
current_path_box = action_map_editor->get_path_box();
} else if (tab == autoload_settings) {
current_path_box = autoload_settings->get_path_box();
} else if (tab == shaders_global_shader_uniforms_editor) {
current_path_box = shaders_global_shader_uniforms_editor->get_name_box();
} else if (tab == group_settings) {
current_path_box = group_settings->get_name_box();
}
if (current_path_box) {
current_path_box->grab_focus();
current_path_box->select_all();
}
}
void ProjectSettingsEditor::_editor_restart() {
ProjectSettings::get_singleton()->save();
EditorNode::get_singleton()->save_all_scenes();