haxe icon indicating copy to clipboard operation
haxe copied to clipboard

hl.UI.chooseFile multiple select support

Open nspitko opened this issue 3 years ago • 1 comments

This is the haxe side change for https://github.com/HaxeFoundation/hashlink/pull/559

This moves a bit of code around, and adds a new function hl.UI.chooseFileMultiple, which is a version of chooseFile 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)

nspitko avatar Aug 31 '22 02:08 nspitko