Hello, I have a table that only displays the painted cell when the column header is clicked. How do I automatically set the column to display the painted cells? Currently the number of rows in the column is empty until the user selects and opens a file, the file name is then passed into drawText and painted in the cell. Thank you
void PlaylistComponent::buttonClicked(Button* button)
{
//JUCE string, to standard string, to integer
// int id = std::stoi(button->getComponentID().toStdString());
//if add to library button is clicked, do...
if (button == &playlistLoadButton)
{
//taken from deckGUI, dr matthew's code version
auto fileChooserFlags = FileBrowserComponent::canSelectMultipleItems;
fChooser.launchAsync(fileChooserFlags, [this](const FileChooser& chooser)
{
//store the chosen tracks into tracks array
tracks = chooser.getResults();
//loop thru the array to add the tracks to the table
for (int i = 0; i < tracks.size(); ++i)
{
//URL takes file parameter, tracks array is of type file
//then store filename as string with method into juce string
trackName = URL{ tracks[i] }.getFileName();
//now push to string array list
trackNameList.add(trackName);
}
});
}
}
void PlaylistComponent::paintCell(Graphics& g, int rowNumber, int columnId, int width, int height, bool rowIsSelected)
{
//draw text of files loaded into the array, see buttonClicked for ref
if (columnId == 1)
{
g.drawText(trackNameList[rowNumber], 5, 0, width-1, height, Justification::centredLeft, true);
}
g.fillRect(width - 1, 0, 1, height);
if (columnId == 2)
{
g.drawText("0:00", 5, 0, width, height, Justification::centredLeft, true);
}
}```