diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-01-14 21:17:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-14 21:17:59 +0100 |
commit | cba3d5f34da13d4ca9b8ddca7887758c5c4c285a (patch) | |
tree | cab16dc7870d51f298d52e33332979cae444d893 /scene/gui | |
parent | 472b5b116742bbb1bdc8197c60efef57c7fd169f (diff) | |
parent | 9dbe314da6d7c0df8df240a401686ea25f3ef086 (diff) |
Merge pull request #56457 from gerhean/focus_file_text_after_popup
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/file_dialog.cpp | 19 | ||||
-rw-r--r-- | scene/gui/file_dialog.h | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index f9b6b1274d..44ef641cb8 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -42,6 +42,17 @@ FileDialog::RegisterFunc FileDialog::unregister_func = nullptr; void FileDialog::popup_file_dialog() { popup_centered_clamped(Size2i(700, 500), 0.8f); + _focus_file_text(); +} + +void FileDialog::_focus_file_text() { + int lp = file->get_text().rfind("."); + if (lp != -1) { + file->select(0, lp); + if (file->is_inside_tree() && !get_tree()->is_node_being_edited(file)) { + file->grab_focus(); + } + } } VBoxContainer *FileDialog::get_vbox() { @@ -688,13 +699,7 @@ void FileDialog::set_current_file(const String &p_file) { file->set_text(p_file); update_dir(); invalidate(); - int lp = p_file.rfind("."); - if (lp != -1) { - file->select(0, lp); - if (file->is_inside_tree() && !get_tree()->is_node_being_edited(file)) { - file->grab_focus(); - } - } + _focus_file_text(); } void FileDialog::set_current_path(const String &p_path) { diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index 782d11afe1..9f8bc02b2a 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -113,6 +113,8 @@ private: void update_file_list(); void update_filters(); + void _focus_file_text(); + void _tree_multi_selected(Object *p_object, int p_cell, bool p_selected); void _tree_selected(); |