FileChooser and filePatternsAllowed

Hi Jules,

    FileChooser myChooser ("Please select the moose you want to load...",
                               File::getSpecialLocation (File::userHomeDirectory),

Currently I can give only one extension, in this case “*.png”, it would be good if we could give multiple file extensions.

Any plans of supporting it ?

Yes, eventually!

Any estimate on when we can see it? :slight_smile:

No idea!

Hi jules,
It looks like you already have support for multiple file types option. This worked with both juce 1.50 and juce 1.39.

   juce::FileChooser	JFFFileChooser ( "Open a File",juce::File::nonexistent,"*.jpg,*.gif");
	if ( JFFFileChooser.browseForFileToOpen() )

Oh, that’s good then! I don’t remember doing it though… Maybe it’s just something that happens to work on the mac when that comma-separated string gets passed through to the OS file chooser?

You have actually coded for it. :smiley:

void FileChooser::showPlatformDialog (OwnedArray<File>& results,
                                      const String& title,
                                      const File& currentFileOrDirectory,
                                      const String& filter,
                                      bool selectsDirectory,
                                      bool isSaveDialogue,
                                      bool warnAboutOverwritingExistingFiles,
                                      bool selectMultipleFiles,
                                      FilePreviewComponent* extraInfoComponent)
    const ScopedAutoReleasePool pool;

    StringArray* filters = new StringArray();
    filters->addTokens (filter.replaceCharacters (T(",:"), T(";;")), T(";"), 0);

     JuceFileChooserDelegate* delegate = [[JuceFileChooserDelegate alloc] initWithFilters: filters];
    [delegate autorelease];

All you need to do is to update the documentation. Pretty sure it will work on pc, will check that later.

Hopefully, this is the end of it. I got it working on both Mac and windows. Final Code.

juce::FileChooser   JFFFileChooser ( "Open a File",juce::File::nonexistent,"*.jpg;*.gif");
   if ( JFFFileChooser.browseForFileToOpen() )

Works on both mac and pc

works on mac, but not on pc.

The only thing am not sure is if it’s default support from the OS or Jules has coded it :wink:. Thanks for prompt replies Jules.

1 Like

Thanks @vishvesh for pointing out the difference in Win/Mac operation with multiple fileTypes.
It should be noted that the JUCE FileChooser documentation still refers to using a comma or a semicolon for fileType separation, but as I discovered (and found this thread) the comma only seems to work on Mac.

I just ran into this. It would be great to update either the documentation or the code so that they match each other!

still broken in Windows in 6.0.5… fix is trivial though.