Unable to override getTooltipForRow on FileListComponent

I have the following simple class that I’m attempting to show the full filename as a tooltip for the items in the FileListComponent.

    class FileListComponentWithTooltips : public juce::FileListComponent
        FileListComponentWithTooltips(juce::DirectoryContentsList& listToShow) : juce::FileListComponent(listToShow)

        juce::String getTooltipForRow(int rowNumber) override
            return directoryContentsList.getFile(rowNumber).getFileName();

For some reason that I’m unable to determine, this getTooltipForRow is never called. Have I done something stupid or is there a reason why FileListComponent will not grab the tooltip?

Apart from the missing tooltips everything works as expected with this sub-class.

edit: For reasons I can’t figure out, ListBox::RowComponent::getTooltip is never called for a FileListComponent, this seems strange, but at least explains how getTooltipForRow is never called, but I’m still flummoxed about why.

I can’t speak to your example specifically; but I just checked my project and I am using getTooltipForRow and it hits.

My specific class is declared as such:

class WaveSelect :  public DialogComponent,
                    public ListBoxModel

    // ListBoxModel virtual methods:
    int getNumRows() override;
    void paintListBoxItem (int rowNumber, Graphics& g, int width, int height, bool rowIsSelected) override;
    void selectedRowsChanged (int /*lastRowselected*/) override;
    void listBoxItemDoubleClicked (int row, const MouseEvent &) override;
    void returnKeyPressed (int lastRowSelected) override;
    String getTooltipForRow (int /*row*/) override { return list.getTooltip(); }

     ListBox list;     // the list component itself

I don’t know if that helps in any way…

Maybe something with the ListBoxModel…

In my constructor, among other things, I call:

    list.setModel (this);
1 Like

I’ve also used getTooltipForRow in other ListBoxModel successfully too. Decided the pragmatic approach was just to copy-pasta FileListComponent into my codebase and then I updated FileListComponent::ItemComponent to inherit SettableTooltipClient and set the tooltip in the update method, which works but is a lot more painful than what I thought should have been possible with a simple sub-class. :person_shrugging:

FileListComponent is inheriting ListBoxModel and ListBox, the ListBox is initialised with an empty String and this for its ListBoxModel from the FileListComponent, so I suppose that might be why my sub-class would not work, but I even tried implementing getTooltipForRow in FileListComponent and was never called, as mentioned in my “edit” above, the ListBox::RowComponent::getTooltip method is never even called, so it wouldn’t get a chance to interrogate the model anyway.

It’s not at all important, but I’d love to understand why this is all happening, as I was unable to determine it for myself.

Thanks for reporting, looks like this was an oversight in the implementation. It should be fixed here:


Thanks for the prompt fix, works perfectly!