Hello.
When using browseForFileToSave
, the FileChooser returns false when the user cancels the dialog. But I can’t seem to find an equivalent when using launchAsync
in save mode. Checking for File::existsAsFile()
returns false, so the only workaround I have found is to check for an empty file name. Is there a better way to handle this?
chooser->launchAsync(juce::FileBrowserComponent::saveMode | juce::FileBrowserComponent::canSelectFiles |
juce::FileBrowserComponent::warnAboutOverwriting,
[this](const juce::FileChooser& c) {
proc.suspendProcessing(true);
auto f = c.getResult();
if (f.getFileName().isNotEmpty()) {
const auto t = pluginState.copyState();
auto xml = t.createXml();
if (xml != nullptr) {
xml->writeTo(f);
currentName = f.getFileNameWithoutExtension();
}
}
proc.suspendProcessing(false);
});