# How to prevent child component from taking mouse focus

**URL:** <https://forum.juce.com/t/how-to-prevent-child-component-from-taking-mouse-focus/33634>\
**Category:** General JUCE discussion\
**Created:** [May 29, 2019, 10:02am UTC](https://forum.juce.com/t/how-to-prevent-child-component-from-taking-mouse-focus/33634 "2019-05-29T10:02:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaukomedia](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@kaukomedia](https://forum.juce.com/u/kaukomedia)\
**Post date:** [May 29, 2019, 10:02am UTC](https://forum.juce.com/t/how-to-prevent-child-component-from-taking-mouse-focus/33634/1 "2019-05-29T10:02:46Z")

</div>

Hi!

I’m not even sure how to properly ask this but I have child components that are plainly for visuals and they should not affect the parent component’s mouse focus. Is there a way to make components “invisible” to mouse so that the parent component would always receive mouse events when the mouse is inside that component even if a child component is under the mouse?

---

<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:** [May 29, 2019, 10:27am UTC](https://forum.juce.com/t/how-to-prevent-child-component-from-taking-mouse-focus/33634/2 "2019-05-29T10:27:33Z")

</div>

Yes, there is [Component::setInterceptsMouseClicks()](https://docs.juce.com/develop/classComponent.html#ac9fdcb595c1878201a641de2e1159aec).

This switches the hitTest to return false every time, so any mouse event will see through this component (or through its children, depending, which bool flag you set).  
Despite the name it effects mouseEnter and mouseExit as well.

---

<div class="post-metadata">

**Author:** ![kaukomedia](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@kaukomedia](https://forum.juce.com/u/kaukomedia)\
**Post date:** [May 29, 2019, 11:02am UTC](https://forum.juce.com/t/how-to-prevent-child-component-from-taking-mouse-focus/33634/3 "2019-05-29T11:02:13Z")

</div>

AH! I thought it would only affect clicks… Thank you so much!! 🙂
