I’m using the FileChooserDialogBox as a ‘save as’ dialog, and I noticed that the save button only becomes available when a file is selected in the chooser window, but incorrectly stays unavailable if a file name is typed in (IE you are creating not overwriting a file).
On a side note, I’m noticing that the FileChooserDialogBox components are really slow on some systems. Is anyone else seeing this?
I’ve just had a possible thought. I can’t verify this as I’m not near one of the machines that performs slowly, but it might be related to machines that have floppy drives.
It takes about 6 seconds for the file chooser dialog to show, then around 2 seconds for a directory change.
The directory change bit is throwing me though, as this shouldn’t really be affected by the presence of a floppy drive, or network drive. :?
I don’t have anything with a floppy drive in it these days, but looking through the code, there’s a chance that it could glitch while it looks up the names of the root drives. Try this instead, at about line 438 of juce_FileBrowserComponent.cpp:
[code] for (int i = 0; i < roots.size(); ++i)
{
const File* const drive = roots.getUnchecked(i);
String name (drive->getFullPathName());
rootPaths.add (name);
if (drive->isOnHardDisk())
{
String volume (drive->getVolumeLabel());
if (volume.isEmpty())
volume = T("Hard Drive");
name << T(" [") << drive->getVolumeLabel() << T(']');
}
else if (drive->isOnCDRomDrive())
{
name << T(" [CD/DVD drive]");
}
rootNames.add (name);
}
[/code]
With this code it won’t try to look-up the name of any volume that’s not a hard-drive.
I modified the first fix to also deal with loading files. I imagine you’ve already something like this, but for anyone else reading this thread before the next JUCE release:
void FileBrowserComponent::textEditorTextChanged (TextEditor&)
{
if ((mode == saveFileMode) ||
((mode == loadFileMode) && (getCurrentFile().existsAsFile())))
{
ComponentDeletionWatcher deletionWatcher (this);
for (int i = listeners.size(); --i >= 0;)
{
((FileBrowserListener*) listeners.getUnchecked (i))->selectionChanged();
if (deletionWatcher.hasBeenDeleted()) return;
i = jmin (i, listeners.size() - 1);
}
}
}
Ideally I’d change this code so that the choose button disables as well for loadFileMode if the text is not a valid file. Currently ocne it enables, it stays enabled. The list select handler should also clear the text box when a directory is clicked (and cause a corresponding disable button event). I’l l take a look at that after lunch.
The dialog box performance now seems to be what I’d expect on all machines I’ve tested on, so I guess it was the root building that was taking so long. Odd that the floppy drive never grunted though.
hmm - not sure about your change, because it won’t send a change message when you alter the text from a real file to a non-existent one. Probably better to lose the ‘if’ statement altogether and just do:
void FileBrowserComponent::textEditorTextChanged (TextEditor&)
{
ComponentDeletionWatcher deletionWatcher (this);
for (int i = listeners.size(); --i >= 0;)
{
((FileBrowserListener*) listeners.getUnchecked (i))->selectionChanged();
if (deletionWatcher.hasBeenDeleted()) return;
i = jmin (i, listeners.size() - 1);
}
}