FileBrowserComponent changes

I noticed changes a while ago to my file browsers (when getCurrentFile disappeared).

I replaced getCurrentFile with getHighlightedFile … and assumed it was equivalent. It seems that get highlighted file returns empty if the user selects a directory, then types in a filename? (in save mode of course)

I looked through the class and couldn’t find another function that looked right … so I’m confused.

I’ve noticed that clicking on a file works fine (returning that file) … but if no file is highlighted, and the user has just double clicked into a directory then typed a filename into the box … it seems to come back as an empty string.

Also, you may also want to update the docs online (which still have getCurrentFile() listed).

                   WildcardFileFilter wildcardFilter (T("*.wav, *.mp3"), T("*"), T("audio files"));

		FileBrowserComponent browser (FileBrowserComponent::saveMode | FileBrowserComponent::canSelectFiles,
			&wildcardFilter,	 0);

		FileChooserDialogBox dialogBox (T("Export Loops as Wav file"),
			T("Please designate a location and name for these loops."),
			browser, true, Colours::grey);

		if (
			File selectedFile = browser.getHighlightedFile();
			juce::Logger::outputDebugString (selectedFile.getFullPathName());
			File outputFile = File(browser.getHighlightedFile().getFullPathName() + String(".wav"));
** crashes here ********

it crashes on an assertion on line 175 of File.cpp (because it thinks the path is relative, since the getHighlighted File returns String::empty)

Don’t you just want getSelectedFile()?

If you need even more control, you could also add a FileBrowserListener to get told when anything gets selected.

yeah, found it just after posting. Thanks -