hl.UI.chooseFile multiple select support #10788
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the haxe side change for HaxeFoundation/hashlink#559
This moves a bit of code around, and adds a new function
hl.UI.chooseFileMultiple
, which is a version ofchooseFile
that is always a load, and returns a path plus array of files.The return format was chosen largely due to how the windows API works, so I'm not married to it if someone wants a different return format. I also would prefer a
@:structInit
class here (especially in hl) but I wanted to maintain consistency with the existing code.Relevant API docs: https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-openfilenamea
Essentially this function takes the result from the hl-side chooseFile wrapper and breaks it up into a consistent haxe return. The code is fairly straightforward; we need to dig out each string in the return value, looking for the end marker (two nulls). We then handle the special case for a single file by breaking it out to keep the haxe side API consistent.
If this commit is accepted before the hashlink pull, the function will still function correctly, but not allow multiple file selections in the ui dialogue (making it basically useless, but not crashy/dangerous)