Skip to content

Commit 66faae4

Browse files
committed
Fix Set focus on right control on user action "show in file system"
1 parent 1cf573f commit 66faae4

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
@@ -710,7 +710,7 @@ void FileSystemDock::_set_current_path_line_edit_text(const String &p_path) {
710710
}
711711
}
712712

713-
void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_favorites) {
713+
void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_favorites, bool p_grab_focus) {
714714
String target_path = p_path;
715715
bool is_directory = false;
716716

@@ -763,9 +763,15 @@ void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_fa
763763
}
764764
item = item->get_next();
765765
}
766+
if (p_grab_focus) {
767+
tree->grab_focus();
768+
}
766769
} else {
767770
(*directory_ptr)->select(0);
768771
_update_file_list(false);
772+
if (p_grab_focus) {
773+
files->grab_focus();
774+
}
769775
}
770776
tree->ensure_cursor_is_visible();
771777
}
@@ -802,10 +808,10 @@ bool FileSystemDock::_update_filtered_items(TreeItem *p_tree_item) {
802808

803809
void FileSystemDock::navigate_to_path(const String &p_path) {
804810
file_list_search_box->clear();
805-
_navigate_to_path(p_path);
806-
807-
// Ensure that the FileSystem dock is visible.
811+
// Try to set the FileSystem dock visible.
808812
EditorDockManager::get_singleton()->focus_dock(this);
813+
_navigate_to_path(p_path, false, is_visible_in_tree());
814+
809815
import_dock_needs_update = true;
810816
_update_import_dock();
811817
}

editor/filesystem_dock.h

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

255255
void _file_list_gui_input(Ref<InputEvent> p_event);

0 commit comments

Comments
 (0)