I am working with the juce demo code to make a mp3 player. I want to save the file selected and open to that place when started next time it is opened. The code uses a FileTreeComponent, to display directoryList. So after the FileTreeComponent is opened I try to use setSelectedFile to do this but does not work. I must be misunderstanding. Here is a clipe of my code:
directoryList.setDirectory (g_Properties->getValue("PlayDirectory", ""), true, true);// set the directory last opened
The play directory is "E:\\" and LastPlayed is somethinglike "E:\\album\\song.mp3"". These were saved like this:
The setDirectory works correctly, the setSelectedFile does nothing. Stepping through I get here:
void FileTreeComponent::setSelectedFile (const File& target)
if (FileListTreeItem* t = dynamic_cast <FileListTreeItem*> (getRootItem()))
if (! t->selectFile (target))
selectFile does this:
if (file == target)
setSelected (true, true);
if (target.isAChildOf (file))
Of course my file does not match "" so it falls to the second if. The next if calls:
bool File::isAChildOf (const File& potentialParent) const
This returns false.
I assume that the getRootItem is the problem. Do I need to setup the rootItem somehow or am I going about this in the wrong way?