mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
FileListComponent: Fix incorrect selection when calling setSelectedFile while the directory contents are still loading
This commit is contained in:
parent
4fc958bcda
commit
5d1c580b15
2 changed files with 11 additions and 9 deletions
|
|
@ -31,12 +31,11 @@ Image juce_createIconForFile (const File& file);
|
|||
|
||||
//==============================================================================
|
||||
FileListComponent::FileListComponent (DirectoryContentsList& listToShow)
|
||||
: ListBox ({}, nullptr),
|
||||
: ListBox ({}, this),
|
||||
DirectoryContentsDisplayComponent (listToShow),
|
||||
lastDirectory (listToShow.getDirectory())
|
||||
{
|
||||
setTitle ("Files");
|
||||
setModel (this);
|
||||
directoryContentsList.addChangeListener (this);
|
||||
}
|
||||
|
||||
|
|
@ -67,14 +66,17 @@ void FileListComponent::scrollToTop()
|
|||
|
||||
void FileListComponent::setSelectedFile (const File& f)
|
||||
{
|
||||
for (int i = directoryContentsList.getNumFiles(); --i >= 0;)
|
||||
if (! directoryContentsList.isStillLoading())
|
||||
{
|
||||
if (directoryContentsList.getFile (i) == f)
|
||||
for (int i = directoryContentsList.getNumFiles(); --i >= 0;)
|
||||
{
|
||||
fileWaitingToBeSelected = File();
|
||||
if (directoryContentsList.getFile (i) == f)
|
||||
{
|
||||
fileWaitingToBeSelected = File();
|
||||
|
||||
selectRow (i);
|
||||
return;
|
||||
selectRow (i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@ namespace juce
|
|||
|
||||
@tags{GUI}
|
||||
*/
|
||||
class JUCE_API FileListComponent : public ListBox,
|
||||
class JUCE_API FileListComponent : private ListBoxModel,
|
||||
public ListBox,
|
||||
public DirectoryContentsDisplayComponent,
|
||||
private ListBoxModel,
|
||||
private ChangeListener
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue