Native Save As Dialog Issue on Windows

I’ve recently noticed an issue with the FileChooser on Windows. I’m trying to add a “save as” dialog which saves a folder with files inside, but if I use the flags “saveMode | canSelectDirectories,” no dialog appears and it returns with an empty file.

If I use just “saveMode,” the default name in the name field of the dialog shows up as “name.name” when it should just be “name”.

If I add “canSelectFiles,” it replaces the native dialog with an internal JUCE one which works as expected but I was hoping to be able to use a native window.

No such issues on Mac.

Is this a bug?

Example code for reference:

fileChooser = std::make_unique<FileChooser>("Export As", defDir);

auto folderChooserFlags =   FileBrowserComponent::saveMode |
                                FileBrowserComponent::canSelectDirectories;

    chooser->launchAsync(folderChooserFlags, [this] (const FileChooser& chooser)
    {
        auto outFile = chooser.getResult();
        auto newDefDir = outFile.getParentDirectory().getFullPathName();
    });
1 Like

I would try openMode if you want to select a directory.

I have the same problem as SHarbor.
OpenMode does not really do the trick. Because I want users to be able to enter/create new directory names. Which they can’t with OpenMode.

What I find weird:
If on Windows you create a native file browser with the flags:
FileBrowserComponent::saveMode | FileBrowserComponent::canSelectDirectories;
Then nothing happens. The file browser simply never shows up. If this combination is not allowed, I would expect a fallback to the JUCE internal file browser or a jassert. But that’s not the case. Which makes me think its a JUCE bug and not a Windows problem.

Experienced the same issues with the name.name preselection and it turns out it’s an easy fixable Juce Bug. There is a wrong use of fromLastOccurrenceOf in the Juce code here If there is no “.” in the given string fromLastOccurrenceOf returns the whole string but we want an empty string in this case. There is probably a nicer way but replacing the line with this code does the trick:

        String extension;
        if (filename.contains(".")) {
        extension = filename.fromLastOccurrenceOf(".", false, false);
        }        
        

@reuk Can this be updated or does it have some side effects?

Thanks for reporting, that’s fixed here:

1 Like

Thanks alot for the fast response! Really appreciate the commitment of the Juce team