Hello,
in my plugins I was always using FileChooser::browseForFileToOpen()
to open files.
But after last update of JUCE and Projucer I can’t do that.
It looks like macro JUCE_MODAL_LOOPS_PERMITTED
is set to false, so browseForFileToOpen()
is not even declared in that case.
I’ve read (link to post) that I should now use launchAsync()
.
But actually it doesn’t work for me. When I call launchAsync()
there is no action. Just nothing happens, no window is opened. I have no idea what I do wrong.
My code looks like that:
String defaultPath = File::getSpecialLocation(File::SpecialLocationType::userApplicationDataDirectory).getFullPathName();
File defaultDirectory = File(defaultPath );
std::unique_ptr<FileChooser> fChooser;
fChooser = std::make_unique<FileChooser>("Choose file", defaultDirectory, "*.txt", true, false, this);
auto folderChooserFlags = FileBrowserComponent::openMode | FileBrowserComponent::canSelectDirectories;
fChooser->launchAsync(folderChooserFlags, [this](const FileChooser& chooser)
{
File chosenFile = chooser.getResult();
// here is my code to handle chosen files data
});
I also tried other variations of folderChooserFlags
, and nothing happens, but in one case I get runtime error, when my flags looked like that:
int folderChooserFlags = juce::FileBrowserComponent::canSelectFiles | juce::FileBrowserComponent::openMode | FileBrowserComponent::canSelectDirectories;
then I got error:
Exception thrown: read access violation.
in the functional
file in line:
return (_Mystorage._Ptrs[_Small_object_num_ptrs - 1]);
Please help me.
For any advice great thanks in advance.