Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Implement native file selection dialog support. #79574

Merged
merged 1 commit into from
Jul 18, 2023

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Jul 17, 2023

Follow up to #47499

Implements DisplayServer.file_dialog_show() for Windows.

@YuriSizov
Copy link
Contributor

The passthrough option from the FileDialog seems to work correctly. But when calling DisplayServer.file_dialog_show(), I can't seem to change the current directory with any of these:

DisplayServer.file_dialog_show("Hello!", ".", "", false, DisplayServer.FILE_DIALOG_MODE_OPEN_ANY, [], _callback)
DisplayServer.file_dialog_show("Hello!", "res://", "", false, DisplayServer.FILE_DIALOG_MODE_OPEN_ANY, [], _callback)
DisplayServer.file_dialog_show("Hello!", ProjectSettings.globalize_path("res://"), "", false, DisplayServer.FILE_DIALOG_MODE_OPEN_ANY, [], _callback)
DisplayServer.file_dialog_show("Hello!", "C:/", "", false, DisplayServer.FILE_DIALOG_MODE_OPEN_ANY, [], _callback)
DisplayServer.file_dialog_show("Hello!", "C:\\", "", false, DisplayServer.FILE_DIALOG_MODE_OPEN_ANY, [], _callback)

It always opens the user directory instead. Windows 11 by the way.

@KoBeWi
Copy link
Member

KoBeWi commented Jul 18, 2023

Tested on Windows 10, I also can't change current directory.
Although it does not always open in user. It opens the last directory I picked something from. I observed such behavior in various apps (most notably in Chrome), so it's at least consistent with how native file dialogs usually work on Windows.

EDIT:
btw when native file dialog is opened, the Godot window becomes unresponsive.

@bruvzg bruvzg marked this pull request as draft July 18, 2023 13:27
@bruvzg bruvzg marked this pull request as ready for review July 18, 2023 14:24
@bruvzg
Copy link
Member Author

bruvzg commented Jul 18, 2023

Setting directory should be fixes.

@YuriSizov YuriSizov modified the milestones: 4.x, 4.2 Jul 18, 2023
@YuriSizov YuriSizov merged commit e8aa8c1 into godotengine:master Jul 18, 2023
13 checks passed
@YuriSizov
Copy link
Contributor

Thanks!

@KoBeWi
Copy link
Member

KoBeWi commented Jul 18, 2023

And what about the unresponsive background window? 🙃

@YuriSizov
Copy link
Contributor

I think that might be by design? Isn't it always blocking the main window when a native app brings that dialog? But feel free to open the issue.

@bruvzg
Copy link
Member Author

bruvzg commented Jul 18, 2023

And what about the unresponsive background window? 🙃

Have not seen the edit, the function is blocking, and I am not sure if there's a way to plug in redraw into its modal event loop. But I dialog can be shown from a thread, I'll take a look if it can be improved.

@KoBeWi
Copy link
Member

KoBeWi commented Jul 18, 2023

I checked how Chrome handles it. When you click outside the dialog, the dialog will briefly blink and play the Background sound.

EDIT:
Opened an issue: #79642

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants