| @@ -65,6 +65,7 @@ FileBrowserComponent::FileBrowserComponent (int flags_, | |||||
| } | } | ||||
| fileList.reset (new DirectoryContentsList (this, thread)); | fileList.reset (new DirectoryContentsList (this, thread)); | ||||
| fileList->setDirectory (currentRoot, true, true); | |||||
| if ((flags & useTreeView) != 0) | if ((flags & useTreeView) != 0) | ||||
| { | { | ||||
| @@ -124,6 +125,9 @@ FileBrowserComponent::FileBrowserComponent (int flags_, | |||||
| setRoot (currentRoot); | setRoot (currentRoot); | ||||
| if (filename.isNotEmpty()) | |||||
| setFileName (filename); | |||||
| thread.startThread (4); | thread.startThread (4); | ||||
| startTimer (2000); | startTimer (2000); | ||||
| @@ -66,7 +66,12 @@ public: | |||||
| @param initialFileOrDirectory the file or directory that should be selected | @param initialFileOrDirectory the file or directory that should be selected | ||||
| when the dialog box opens. If this parameter is | when the dialog box opens. If this parameter is | ||||
| set to File(), a sensible default directory will | set to File(), a sensible default directory will | ||||
| be used instead. | |||||
| be used instead. When using native dialogs, not | |||||
| all platforms will actually select the file. For | |||||
| example, on macOS, when initialFileOrDirectory is | |||||
| a file, only the parent directory of | |||||
| initialFileOrDirectory will be used as the initial | |||||
| directory of the native file chooser. | |||||
| Note: on iOS when saving a file, a user will not | Note: on iOS when saving a file, a user will not | ||||
| be able to change a file name, so it may be a good | be able to change a file name, so it may be a good | ||||
| @@ -33,7 +33,8 @@ Image juce_createIconForFile (const File& file); | |||||
| //============================================================================== | //============================================================================== | ||||
| FileListComponent::FileListComponent (DirectoryContentsList& listToShow) | FileListComponent::FileListComponent (DirectoryContentsList& listToShow) | ||||
| : ListBox ({}, nullptr), | : ListBox ({}, nullptr), | ||||
| DirectoryContentsDisplayComponent (listToShow) | |||||
| DirectoryContentsDisplayComponent (listToShow), | |||||
| lastDirectory (listToShow.getDirectory()) | |||||
| { | { | ||||
| setModel (this); | setModel (this); | ||||
| directoryContentsList.addChangeListener (this); | directoryContentsList.addChangeListener (this); | ||||
| @@ -70,12 +71,15 @@ void FileListComponent::setSelectedFile (const File& f) | |||||
| { | { | ||||
| if (directoryContentsList.getFile(i) == f) | if (directoryContentsList.getFile(i) == f) | ||||
| { | { | ||||
| fileWaitingToBeSelected = File(); | |||||
| selectRow (i); | selectRow (i); | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| deselectAllRows(); | deselectAllRows(); | ||||
| fileWaitingToBeSelected = f; | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -85,9 +89,13 @@ void FileListComponent::changeListenerCallback (ChangeBroadcaster*) | |||||
| if (lastDirectory != directoryContentsList.getDirectory()) | if (lastDirectory != directoryContentsList.getDirectory()) | ||||
| { | { | ||||
| fileWaitingToBeSelected = File(); | |||||
| lastDirectory = directoryContentsList.getDirectory(); | lastDirectory = directoryContentsList.getDirectory(); | ||||
| deselectAllRows(); | deselectAllRows(); | ||||
| } | } | ||||
| if (fileWaitingToBeSelected != File()) | |||||
| setSelectedFile (fileWaitingToBeSelected); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -76,7 +76,7 @@ public: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| File lastDirectory; | |||||
| File lastDirectory, fileWaitingToBeSelected; | |||||
| class ItemComponent; | class ItemComponent; | ||||
| void changeListenerCallback (ChangeBroadcaster*) override; | void changeListenerCallback (ChangeBroadcaster*) override; | ||||