I am using a Native
FileChooser to save and load files. I want to open the
FileChooser in the most recently used directory by any previous
FileChoosers AND pre-populate the
FileChooser file name field. I have been able to satisfy both of these constraints separately but not together.
1. FileChooser opens most recently used directory
FileChooser myChooser ("Save a File"); if (myChooser.browseForFileToSave(true)) // Save the file . . .
In this instance, the constructor for
FileChooser chooses a “sensible default directory” (as explained in the constructor documentation) and has the most recent directory behavior I want. The next
FileChooser I open will open in the last directory used by the previous
FileChooser. This is the behavior I want for directory placement.
2. FileChooser has pre-populated file name
File filePath; filePath = filePath.getChildFile ("MyFile.txt"); FileChooser myChooser ("Save a File", filePath); if (myChooser.browseForFileToSave(true)) // Save the file . . .
In this instance, my
FileChooser always shows the root directory with the pre-populated file name “MyFile.txt”. So the full path is
/MyFile.txt. This behavior totally makes sense to me, because that is the path that I gave to the
FileChooser. But, is there a way for me to load a
FileChooser to have a pre-populated file name in the most recently used directory?
I have only run my JUCE program on Mac.
In the JUCE source code, I was unable to find where the
FileChooser's constructor parameter
initialFileOrDirectory gets converted from a default
File() to this magical recently used directory that I am looking for. I thought there might be a
File::SpecialLocationType for this, but was unable to find it.
Thanks for any help on this!