Skip to content

Commit

Permalink
Merge pull request #82743 from bruvzg/fd_no_editor
Browse files Browse the repository at this point in the history
[File Dialog] Do not open native file dialogs in the edited scene.
  • Loading branch information
akien-mga committed Oct 4, 2023
2 parents 46b8f4a + 2d9ba45 commit 4321806
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scene/gui/file_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ void FileDialog::_focus_file_text() {
}

void FileDialog::popup(const Rect2i &p_rect) {
#ifdef TOOLS_ENABLED
if (is_part_of_edited_scene()) {
ConfirmationDialog::popup(p_rect);
}
#endif

if (access == ACCESS_FILESYSTEM && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG) && (use_native_dialog || OS::get_singleton()->is_sandboxed())) {
DisplayServer::get_singleton()->file_dialog_show(get_title(), dir->get_text(), file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), filters, callable_mp(this, &FileDialog::_native_dialog_cb));
} else {
Expand All @@ -64,6 +70,13 @@ void FileDialog::popup(const Rect2i &p_rect) {
}

void FileDialog::set_visible(bool p_visible) {
#ifdef TOOLS_ENABLED
if (is_part_of_edited_scene()) {
ConfirmationDialog::set_visible(p_visible);
return;
}
#endif

if (access == ACCESS_FILESYSTEM && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG) && (use_native_dialog || OS::get_singleton()->is_sandboxed())) {
if (p_visible) {
DisplayServer::get_singleton()->file_dialog_show(get_title(), dir->get_text(), file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), filters, callable_mp(this, &FileDialog::_native_dialog_cb));
Expand Down

0 comments on commit 4321806

Please sign in to comment.