[Solved] ComboBox and MouseOver?

I want to give my ComboBox a custom LookAndFeel: Whenever the mouse is over the ComboBox, I want to highlight it.

The problem: A ComboBox has a Label inside, which holds the text of the ComboBox. As soon as the mouse touches the label, it is no longer over the ComboBox (even thoug it is still inside the ComboBox). And therefore the highlighting does not work. 

What is the best way to solve this problem?

setInterceptMouseClicks (false, false) on the child label

Unfortunately the label is a priavte member of ComboBox.

I found a solution. What I have to do is.

- subclass ComboBox

- in the constructor add a mouse listener to @self and tell it to also intercept mouse events of the children

- override mouseEnter and mouseExit and make them call repaint()

- in the LookAndFeel::drawComboBox function use isMouseOver(true). The "true" means that it also includes child components.

Here is a codesnippet:

class ExtendedComboBox : public ComboBox
        addMouseListener(this, true);

    void mouseEnter(const MouseEvent &event) { repaint(); }

    void mouseExit(const MouseEvent &event)  { repaint(); }

And in the LookAndFeel::drawComboBox function:

void MyAppLookAndFeel::drawComboBox(Graphics& g, int width, int height, bool isButtonDown,
    int buttonX, int buttonY, int buttonW, int buttonH, ComboBox& box)
    if (box.isMouseOver(true))

Just had the same problem and then found this. Since the ComboBox constructor is explicitly calling

setRepaintsOnMouseActivity (true);

in its constructor, shouldn’t we expect this to “just work”?

If there is no intent to fix this, can the call be removed and maybe a comment be left, so future developers won’t waste their time with something that can’t work?