How can I override ComboBox getToolTip()?

I’m trying to override ComboBox::getTooltip() so that it displays the current item name. I’m finding that I can override Slider::getTooltip() without a problem, but ComboBox::getTooltip(), ignores my override.

// Works

class MySlider : public Slider
{
public:
    MySlider (const String& name) : Slider (name) {};
    ~MySlider () {};
        
    String getTooltip () override
    {
        return getTextFromValue (Slider::getValue ());
    }
};

// Doesn’t work

class MyComboBox : public ComboBox
{
public:
    MyComboBox (const String& name) : ComboBox (name) {};
    ~MyComboBox () {};

    String getTooltip () override
    {
        return ComboBox::getText ();
    }
};

Could someone tell me how to get this to work?

My guess is that your code partially works : you will probably only have the tooltip you want when you hover the combobox arrow.
That’s because the combobox contains a label, so when you hover the combobox, it’s actually the label’s tooltip that is used.
Perhaps you can simply set the tooltip using setTooltip?

    struct MyComboBox : public ComboBox
    {
        MyComboBox()
        {
            onChange = [this]() { setTooltip (getText()); };
        }
    };

you could also create a customized label in your lookandFeel::createComboBoxTextBox() method

Just in case it’s of any use to anyone, I worked around this like so:

class ComboBoxTT : public Component
{
public:
    ComboBoxTT (const String name) : menu (name)
    {
        addAndMakeVisible (menu);
        menu.onChange = [this]() { menu.setTooltip (menu.getText ()); };
    }
    	    	
    ~ComboBoxTT ()
    {
    }
    	    	
    ComboBox& getComboBox ()
    {
        return menu;
    }

private:
    ComboBox menu;
};