Trying to hightlight (not select) row in ListBox for mouse hover

As the title says, using a ListBox I want to highlight the row which is under the mouse, but not select it.

My approach has been to determine the row by using mouse position with ListBox::getRowContainingPosition, and doing the highlight in ListBoxModel::paintListBoxItem.

But, since the ListBox is a composite Component, I can’t just capture the ListBox mouse events to track mouse location.

So I thought I would reach out to the hive mind and see if anyone has done something similar, or has some suggestions.

Thanks in advance. :slight_smile:

Hi there,
in the past I solved this by using custom components (ListBox::refreshComponentForRow) and by overriding mouseEnter and mouseExit, e.g:

void CustomRowComponent::mouseEnter(const juce::MouseEvent& e)
{
    mouseIn = true;
    repaint();
}
    
void CustomRowComponent::mouseExit(const juce::MouseEvent& e)
{
    mouseIn = false;
    repaint();
}

Let me know if this can help!