# Component which is not MouseListener - is that possible?

**URL:** https://forum.juce.com/t/component-which-is-not-mouselistener-is-that-possible/47717
**Category:** General JUCE discussion
**Created:** [September 8, 2021, 12:07pm UTC](https://forum.juce.com/t/component-which-is-not-mouselistener-is-that-possible/47717 "2021-09-08T12:07:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pajczur](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pajczur](https://forum.juce.com/u/pajczur)
#### Post date: [September 8, 2021, 12:07pm UTC](https://forum.juce.com/t/component-which-is-not-mouselistener-is-that-possible/47717/1 "2021-09-08T12:07:30Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

### Author: ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)
#### Post date: [September 8, 2021, 12:16pm UTC](https://forum.juce.com/t/component-which-is-not-mouselistener-is-that-possible/47717/2 "2021-09-08T12:16:02Z")

</div>

You can get this effect by calling [setInterceptsMouseClicks (false, false)](https://docs.juce.com/master/classComponent.html#ac9fdcb595c1878201a641de2e1159aec). This will stop all mouse events (including mouseEnter and mouseExit) from being processed, which means they will be handled by the parent.

---

<div class="post-metadata">

### Author: ![pajczur](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pajczur](https://forum.juce.com/u/pajczur)
#### Post date: [September 8, 2021, 1:02pm UTC](https://forum.juce.com/t/component-which-is-not-mouselistener-is-that-possible/47717/3 "2021-09-08T13:02:52Z")

</div>

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