FileChooser class - change or bug?

Hey Jules
I’ve just updated the JUCE library within one of my apps from version 2.0.28 to the very latest version, and I’ve noticed a slight change in the way that the FileChooser class works when using it to save a file.

When using the following code, the getResult() function is now returning something slightly different:

FileChooser saveFileChooser(translate("Create an AlphaLive project to save..."), 
                                StoredSettings::getInstance()->appProjectDir, 
                                "*.alphalive");
    
if (saveFileChooser.browseForFileToSave(false))
{
   //create a project directory
   File savedDirectory (saveFileChooser.getResult());
}

Previously, the filename that getResult() would return would be exactly what text the user entered into the file browser window, however with the very latest version it automatically appends the first wildcard I put as the filePatternsAllowed parameter within the FileChoose constructor (in this case, .alphalive).

Is this the way that it is meant to work now?

I don’t remember deliberately changing anything. Which OS is it?

Tested it on OS X 10.6, haven’t had a chance to try it on Windows yet.

Just tested this on Windows 7. It has changed for me there too.

Well looking at the code, it’s just returning the path directly from the OS-supplied methods, and not doing anything funny to it. I don’t think this is “wrong”. I seem to remember fixing an old problem where the extensions weren’t being correctly sent to the OS, so perhaps the behaviour you wanted was actually just a side-effect of an old bug?

Ah OK.
Well just setting the filePatternsAllowed parameter to String::empty changes the implementation back to what I had before, so there’s no problem. I was mainly just checking to see if this behaviour was likely to change again or not.

Though it would be interesting to see how the filePatternsAllowed patterns could be utilised better when saving files. At the moment both OS X and Windows will automatically use the first pattern as the files extension, however in general both OS’s file browser windows usually allow the user to select from a list of file extensions. With JUCE applications on Windows (tested on Win7) this option is provided using a “Save as type” drop down menu, however it puts all extensions into a single item in the menu so you are unable to choose an individual file extension. OS X (tested on 10.6) can have a “Format” drop down menu that does the same thing, however this doesn’t seem to appear within JUCE applications. Also it seems like both accept names/descriptions for the file types/formats as well.

I’ve never dug too deeply into the way OSX handles that, I’m afraid… The place to look at would be in juce_mac_FileChooser.mm, around line 140 - there may be a setting that you can flip to do what you need…