Mouse events don't work [user error, not a bug]

I just started using Juce GUI library for c++. I am trying to create custom listbox where I will display file names later. Now I need to change the background color of the rows of this custom listbox when mouse is in/out/clicked. The problem is that MouseEnter(), MouseExit() and MouseUp() don’t work. Here is the code:

class LeftExplorerItem : public Component, public MouseListener {


LeftExplorerItem(String name = "LeftExplorerItem") : Component(name), isActive(false) {

	addMouseListener(this, true);


void paint(Graphics& g) override {

	if (!isActive) g.setColour(Colour(40, 40, 40));
	else g.setColour(Colour(150, 190, 255));
	g.fillRoundedRectangle(2, 2, getWidth() - 4, getHeight() - 4, 4);


	g.drawText("Frame #", 40, 0, 100, 25, Justification::centredLeft);



void mouseEnter(const MouseEvent& event) override {
	AlertWindow("", "", AlertWindow::AlertIconType::InfoIcon);
	isActive = true;


void mouseExit(const MouseEvent& event) override {

	isActive = false;


void mouseUp(const MouseEvent& event) override {
	AlertWindow("", "click", AlertWindow::AlertIconType::InfoIcon);

void resized() override {



bool isActive;


This is just the class for each item of my custom listbox. Keep in mind that everything appears okay (listbox, all listbox items, etc) the only problem is that mouse events never get triggered. What is missing here?

Maybe you shouldn’t inherit from MouseListener since Component inherits from that already…

I tried that. Still nothing.

You definitely don’t need to derive from MouseListener since the Component base class already does… Is your Component being occluded by another Component?


Okay, mouse events work great I just couldn’t see it because I didn’t repaint.