Skip to content

Commit 8e744e6

Browse files
committed
Merge pull request godotengine#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"
2 parents a2aefab + 66faae4 commit 8e744e6

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

editor/filesystem_dock.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ void FileSystemDock::_set_current_path_line_edit_text(const String &p_path) {
714714
}
715715
}
716716

717-
void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_favorites) {
717+
void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_favorites, bool p_grab_focus) {
718718
String target_path = p_path;
719719
bool is_directory = false;
720720

@@ -767,9 +767,15 @@ void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_fa
767767
}
768768
item = item->get_next();
769769
}
770+
if (p_grab_focus) {
771+
tree->grab_focus();
772+
}
770773
} else {
771774
(*directory_ptr)->select(0);
772775
_update_file_list(false);
776+
if (p_grab_focus) {
777+
files->grab_focus();
778+
}
773779
}
774780
tree->ensure_cursor_is_visible();
775781
}
@@ -806,10 +812,10 @@ bool FileSystemDock::_update_filtered_items(TreeItem *p_tree_item) {
806812

807813
void FileSystemDock::navigate_to_path(const String &p_path) {
808814
file_list_search_box->clear();
809-
_navigate_to_path(p_path);
810-
811-
// Ensure that the FileSystem dock is visible.
815+
// Try to set the FileSystem dock visible.
812816
EditorDockManager::get_singleton()->focus_dock(this);
817+
_navigate_to_path(p_path, false, is_visible_in_tree());
818+
813819
import_dock_needs_update = true;
814820
_update_import_dock();
815821
}

editor/filesystem_dock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class FileSystemDock : public VBoxContainer {
254254
Ref<Texture2D> _get_tree_item_icon(bool p_is_valid, const String &p_file_type, const String &p_icon_path);
255255
void _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path = false);
256256
void _update_tree(const Vector<String> &p_uncollapsed_paths = Vector<String>(), bool p_uncollapse_root = false, bool p_scroll_to_selected = true);
257-
void _navigate_to_path(const String &p_path, bool p_select_in_favorites = false);
257+
void _navigate_to_path(const String &p_path, bool p_select_in_favorites = false, bool p_grab_focus = false);
258258
bool _update_filtered_items(TreeItem *p_tree_item = nullptr);
259259

260260
void _file_list_gui_input(Ref<InputEvent> p_event);

0 commit comments

Comments
 (0)