Component which is not MouseListener - is that possible?

Hello,
I have array of Component. I want to use all Component features, but I want to make all of them to not listen any mouse events. So I wonder if it’s ok to call in my Component constructor removeMouseListener(this);
Like that:

class MyComponent : public Component
{
public:
    MyComponent() { removeMouseListener(this); };
};

I want to do that because I want to use only parent Component as a mouse listener. Of course I know I can call in MyComponent::addMouseListener(&parentComponent); And then I will get all mouse events from MyComponent in ParentComponent. But in that case MyComponent will also receive mouse events, but I don’t need them inside MyComponent, it’s only cause not needed calling MyComponent::mouseEnter(), MyComponent::mouseDrag(), etc.

You can get this effect by calling setInterceptsMouseClicks (false, false). This will stop all mouse events (including mouseEnter and mouseExit) from being processed, which means they will be handled by the parent.

Great thanks. It works. Now I remember, I used it before, but forgot. Thanks for remind :slight_smile: