FileChooser::browseForDirectory improvment


#1

Hi,

As the title suggest, I’m a bit disappointed by the GUI behaviour of this method. It’s intuitive if you’re selecting a folder and then press “Open”.
However if you double click on a folder, you enter the folder (that’s Ok) and the “file” text editor write the folder name, but you can’t press “Open” anymore.
Also, you can write whatever you want in the “file” text editor, which is, for an open directory box, a bit undesirable.

From a user perspective, she doesn’t understand she has to select a directory (even if the title says “Please select a directory”, users don’t read text), so if the “file” editor is editable, she’s lost, looking in folder until some file is found.

From a code perspective, I think adding an option in FileChooser to enable filenameBoxIsReadOnly flag will help,
and this to:

const File FileBrowserComponent::getSelectedFile (int index) const throw()
{
    if (! filenameBox->isReadOnly())
    {
        // Allow opening after folder double-click
        if ((flags & canSelectDirectories) != 0 && filenameBox->getText().isEmpty()) 
            return currentRoot;

        return currentRoot.getChildFile (filenameBox->getText());
    }
    else
        return chosenFiles[index];
}

void FileBrowserComponent::fileDoubleClicked (const File& f)
{
    if (f.isDirectory())
    {
        setRoot (f);
        if ((flags & canSelectDirectories) != 0) filenameBox->setText(String::empty);
    }
[...]

#2

Good stuff, thanks! I’ll take a look at that later today.