Merge pull request #106049 from nklbdev/fix-set-focus-on-right-control-on-user-action-show-in-file-system

Fix Set focus on right control on user action "show in file system"
This commit is contained in:
Thaddeus Crews 2025-05-19 16:22:24 -05:00
commit 8e744e65b8
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
2 changed files with 11 additions and 5 deletions

View file

@ -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();
}

View file

@ -254,7 +254,7 @@ private:
Ref<Texture2D> _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<String> &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path = false);
void _update_tree(const Vector<String> &p_uncollapsed_paths = Vector<String>(), 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<InputEvent> p_event);