Suggestion: Tooltip in TableListBox


#1

Hi,

I needed to display a tooltip associated to cells of a TableListBox. Therefore, I performed the following modifications in Juce:

Make TableListRowComp inherit from TooltipClient:

class TableListRowComp   : public Component, public TooltipClient

Implement the getTooltip() function in TableListRowComp:

    virtual const String getTooltip()
    {
        TableListBoxModel* const model = owner.getModel();

        int x, y;
        getMouseXYRelative(x, y);
        const int columnId = owner.getHeader()->getColumnIdAtX(x);

        if (columnId != 0 && owner.getModel() != 0)
            return owner.getModel()->getCellTooltip(row, columnId);
        else
            return String::empty;
    }

Add a new virtual function in TableListBoxModel:

    virtual String getCellTooltip (int rowNumber, int columnId)
      {return String::empty;}

Tooltips are then used simply by overriding the getCellTooltip() function.

This modification may be included in juce source-tree ?

Francis.


#2

Thanks francis - looks like a good idea to me!