Folder selection with text box

How would I create a text box that would be a folder selection, allowing browse to select the folder?

I guess I should be using:
FileChooser::browseForDirectory()

but how would I poulate the text box field with that?

Sounds like what you need is the FilenameComponent…

What I have done is I created a button with … next to the text box and when the button is clicked I get the folder chooser dialog.
No my question is how to get the chosen directory in to the text box. The main problem being that the directory is of type juce::file and the text box is juce::String. How can I convert the file to string?

I have done the following for the button click code:

void loadDirectory()
{
FileChooser myChooser (“Please select the directory to use…”,
File (SystemStats::getUserHomeDirectory())
);

    if (myChooser.browseForFileToOpen())
    {
        File MyDir (myChooser.getResult());
    }
}

So I need to get MyDir into a string for mat for the textbox.

Sounds like what you need is the FilenameComponent…

Or one of the many File methods that return a string version of the filename…

how would i do that?

how would you do what?

I’m not going to tell you the exact function to use, because it’s obvious that you don’t understand how to use the documentation yet. The juce documentation is one of the most useful pieces of hyperlinked text next to the internet itself, so it will pay you well to understand how to use it.

1] You want to get something from a File that you can put in a text box

(you already know you want a String…)

so…

2] You need to get a String from a File

If you’ve got a File, you’re going to of course want to use one of the File functions… so go to the File page of the docs. Look down the list of functions, and see which ones return a String. Look at their descriptions and see if they’re any use to you.

so I should be able to use the following:
const String& File::getFullPathName(MyDir)

is that the correct function to give me the path, as I do not want the file name, but the path.

I am finding my way around the documentation but I am a casual/part-time developer and new to Juce and Jucer.

I probably need to still learn what you good fellows have already forgotten. I do appreciate that you do not just give it to me on a platter and it makes me learn more.

BTW Juce and Jucer are both brilliant, it is a refreshing ui as opposed to the same old windows ui’s.

that’s right. remember that a File can be a file or a folder, so naturally if it’s a folder the full path is going to be that of the folder.