BR: Mac File Chooser Cmd+A and select all using SHIFT

hello there, using native file chooser on Mac shows a couple of quirks.

This started on my code but was perfectly reproducible using juce 8.0.8 Demo runner.

Repro steps

  • launch juce 8.0.0 Demo Runner (MacOs 15.3.1)
  • select ‘Dialogs Demo.h’ on the Demo browser.
  • select ‘Use Native Windows’ checkbox
  • select Load File browser Button
  • point to a folder with a LOT of files (attaching a test data folder with 2048 text files)

Issues found

  1. CMD+A does not work
  2. trying to select all via selecting first item, then scrolling to the end, then selecting the last item using SHIFT modifier … only selects part of the files.

Notes

  • #2 is time dependent, there seems to be a bottleneck in checking whether a file should be included in the extension list. if you wait a long time the problem goes away (too long for users not experiencing this sadly)
  • you can see #2 effect by scrolling up after doing the SHIFT + click : only groups of files are selected (see image below)
  • same file chooser from other apps e.g. Xcode open… menu on same data do not show this behaviour, neither #1 nor #2

Test data used here
test2048files.zip (496.8 KB)

UPDATE: tested Demo runner after applying the changes mentioned on this post - bud CMD+a still not working

way I think I fixed this on my fork:

Slow un-disabling of files:
Cause seems to be the delegate itself (the c++/objc bridge) : code here
Tested emptying the delegate implementation methods, but no luck needed to just remove it.

The file types are still working, because right after there’s the setAllowedFileTypes code … this is deprecated and should be subbed with setAllowedContentTypes, but so far it works :crossed_fingers: . Also, I’m afraid that “content-types” might be a little more problematic than extensions - very ignorant about this, but not sure how e.g supporting jpg in all of its possible quirks (jpg, jpeg, JPG, JPEG) can translate to a content type : as is? OS takes care of it?

The preview component of course does not work since I removed the delegate - I just added an assert : wanna select multiple files and have a preview? not on my fork.

Select All
the solution in this post is only partially working - because the temp NSMenu is added on the app only if the file chooser is run modally, not on the beginWithCompletionHandler case of launchAsync, so I ended up:

  • adding the select all subitem as the post above describes
  • create and reset and instance of TemporaryMainMenuWithStandardCommands inside FileChooser::Native (only in the case selectMultipleFiles is on)

in the end it’s pretty sketchy, but my issues are fixed. I think the slowness of the delegate is really unsolvable , so maybe official juce could drift into an opt-in delegate, only in case you want the preview … and use setAllowedContentTypes only for the file type patterns.