explorer: add native folder pickers - #29
Conversation
Use IFileOpenDialog to select a folder and return its filesystem path. Signed-off-by: qiannian <qianniancn@gmail.com>
Build filters with embedded NUL terminators and handle single-file multi-select results. Signed-off-by: qiannian <qianniancn@gmail.com>
Use NSOpenPanel to select a single directory and return its path through the existing callback channel. Signed-off-by: qiannian <qianniancn@gmail.com>
843ccfd to
554ef13
Compare
| // application resolves after the dialog closes. | ||
| _FlagNoChangeDir = uint32(0x00000008) | ||
| _FlagNoChangeDir = uint32(0x00000008) | ||
| _FOSNoChangeDir = uint32(0x00000008) |
There was a problem hiding this comment.
Why declare a redundant constant with the same value and semantics as the prior _FlagNoChangeDir?
There was a problem hiding this comment.
They correspond to OFN_NOCHANGEDIR and FOS_NOCHANGEDIR from two different
dialog APIs, but they do have the same value and semantics. I’ll replace
them with one shared constant.
| return "", err | ||
| } | ||
|
|
||
| hr, err := fileDialogCall(dialog, _iModalWindowShow, e.owner.Load()) |
There was a problem hiding this comment.
Should we not attempt to load the owner at the beginning of the method and fail with an error if the owner is unset? Alternatively, we could call the variant of iModalWindowShow that does not require a HWND
There was a problem hiding this comment.
Agreed. I've changed this to load the owner at the start and return an error
if it hasn't been set by ListenEvents.
IFileDialog::Show doesn't have a native overload without an HWND; passing 0
would just create an unowned dialog.
whereswaldon
left a comment
There was a problem hiding this comment.
Historically, I've been reluctant to add a method for choosing directories because it's unclear how to implement it in a cross-browser way in WASM. However, it is clearly useful for many applications, and having most of the desktop OSes supported in one fell swoop is hard to turn down. Thank you for working on this. I have a couple of small questions, but it mostly looks great.
Use the desktop portal directory option to return a selected folder without opening it as a file. Signed-off-by: qiannian <qianniancn@gmail.com>
554ef13 to
f00de61
Compare
|
Thank you, merged. |
Add native folder selection on Linux, macOS, and Windows.
Linux uses the XDG desktop portal directory option and returns the selected path without opening the directory. macOS uses NSOpenPanel as a sheet. Windows uses IFileOpenDialog for folder selection and fixes filter buffers used by the legacy file dialogs.