diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 4060b24e56..6d5e4bea58 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -714,7 +714,7 @@ void FileSystemDock::_set_current_path_line_edit_text(const String &p_path) { } } -void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_favorites) { +void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_favorites, bool p_grab_focus) { String target_path = p_path; bool is_directory = false; @@ -767,9 +767,15 @@ void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_fa } item = item->get_next(); } + if (p_grab_focus) { + tree->grab_focus(); + } } else { (*directory_ptr)->select(0); _update_file_list(false); + if (p_grab_focus) { + files->grab_focus(); + } } tree->ensure_cursor_is_visible(); } @@ -806,10 +812,10 @@ bool FileSystemDock::_update_filtered_items(TreeItem *p_tree_item) { void FileSystemDock::navigate_to_path(const String &p_path) { file_list_search_box->clear(); - _navigate_to_path(p_path); - - // Ensure that the FileSystem dock is visible. + // Try to set the FileSystem dock visible. EditorDockManager::get_singleton()->focus_dock(this); + _navigate_to_path(p_path, false, is_visible_in_tree()); + import_dock_needs_update = true; _update_import_dock(); } diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 19a70f78d9..8c1b80fa4f 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -254,7 +254,7 @@ private: Ref _get_tree_item_icon(bool p_is_valid, const String &p_file_type, const String &p_icon_path); void _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path = false); void _update_tree(const Vector &p_uncollapsed_paths = Vector(), bool p_uncollapse_root = false, bool p_scroll_to_selected = true); - void _navigate_to_path(const String &p_path, bool p_select_in_favorites = false); + void _navigate_to_path(const String &p_path, bool p_select_in_favorites = false, bool p_grab_focus = false); bool _update_filtered_items(TreeItem *p_tree_item = nullptr); void _file_list_gui_input(Ref p_event);