JUCE 7.0.0. MacOS.
I’m just experimenting with getting a FileBrowser working. I’m using a simple example taken from the docs basically. I’m not doing anything with the results; I just want to get the FileBrowser to come up.
When using the non-native option (JUCE style), and specifying useTreeView, it takes like 5 seconds to open the Save dialog, but the Open dialog with the same code opens nearly instantly.
I am specifying my home folder as the root, which contains a lot of files and directories (I suppose), but why does the Open dialog open nearly immediately, while the Save version takes 5 seconds to open?
When NOT using the TreeView option, they both open immediately.
Here is a portion of the relevant code:
std::unique_ptr<juce::FileChooser> myChooser;
bool useNative = false;
bool useTreeView = false;
void MainComponent::openFile()
{
myChooser.reset (new FileChooser ("Please select the file you want to load...",
File::getSpecialLocation (File::userHomeDirectory),
"*", useNative));
auto folderChooserFlags = FileBrowserComponent::openMode
| (useTreeView ? FileBrowserComponent::useTreeView : 0)
| FileBrowserComponent::canSelectFiles;
myChooser->launchAsync (folderChooserFlags, [this] (const FileChooser& chooser)
{
File theFile (chooser.getResult());
if (theFile.exists())
DBG("GOOD!" + theFile.getFullPathName());
else
{
DBG("CANCELLED!");
return;
}
});
}
void MainComponent::saveFile()
{
myChooser.reset (new FileChooser ("Choose a file to save...",
File::getSpecialLocation (File::userHomeDirectory).getChildFile ( "default.txt" ),
"*", useNative));
auto folderChooserFlags = FileBrowserComponent::saveMode
| (useTreeView ? FileBrowserComponent::useTreeView : 0)
| FileBrowserComponent::canSelectFiles;
myChooser->launchAsync (folderChooserFlags, [this] (const FileChooser& chooser)
{
auto result = chooser.getURLResult(); // will be empty if cancelled
if (result.isEmpty())
return;
});
}