# Mouselistener callbacks don't work unless the editor or a subview has received one click

**URL:** <https://forum.juce.com/t/mouselistener-callbacks-dont-work-unless-the-editor-or-a-subview-has-received-one-click/15292>\
**Category:** General JUCE discussion\
**Created:** [August 11, 2015, 10:03am UTC](https://forum.juce.com/t/mouselistener-callbacks-dont-work-unless-the-editor-or-a-subview-has-received-one-click/15292 "2015-08-11T10:03:08Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zoabis](https://avatars.discourse-cdn.com/v4/letter/z/46a35a/32.png) [@Zoabis](https://forum.juce.com/u/Zoabis)\
**Post date:** [August 11, 2015, 10:03am UTC](https://forum.juce.com/t/mouselistener-callbacks-dont-work-unless-the-editor-or-a-subview-has-received-one-click/15292/1 "2015-08-11T10:03:08Z")

</div>

Hi

I'm using Ableton Live 9 on Mac. &nbsp;I noticed that&nbsp;mouseMove &&nbsp;mouseEnter are not called until the GUI receives one mouse click, then everything works fine.

If I then close the editor and reopen it, the same thing.

Am I doing something wrong or is this the correct behaviour?

Thanks

Dave

&nbsp;

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [August 11, 2015, 10:06am UTC](https://forum.juce.com/t/mouselistener-callbacks-dont-work-unless-the-editor-or-a-subview-has-received-one-click/15292/2 "2015-08-11T10:06:22Z")

</div>

Presumably this is OSX? That's how all windows on OSX work - you have to click to focus them first.

---

<div class="post-metadata">

**Author:** ![Zoabis](https://avatars.discourse-cdn.com/v4/letter/z/46a35a/32.png) [@Zoabis](https://forum.juce.com/u/Zoabis)\
**Post date:** [August 11, 2015, 10:08am UTC](https://forum.juce.com/t/mouselistener-callbacks-dont-work-unless-the-editor-or-a-subview-has-received-one-click/15292/3 "2015-08-11T10:08:00Z")

</div>

Yes Jules, it is OS X.

&nbsp;

Thanks for the Swift reply but the window has focus but still needs a click on an actual component&nbsp;

Dave

&nbsp;

---

<div class="post-metadata">

**Author:** ![Zoabis](https://avatars.discourse-cdn.com/v4/letter/z/46a35a/32.png) [@Zoabis](https://forum.juce.com/u/Zoabis)\
**Post date:** [August 11, 2015, 10:10am UTC](https://forum.juce.com/t/mouselistener-callbacks-dont-work-unless-the-editor-or-a-subview-has-received-one-click/15292/4 "2015-08-11T10:10:08Z")

</div>

Sorry, maybe I replied too soon, I had already clicked the bar at the top of the top, turning the left most circle red but needed to click the actual GUI in order for the callbacks to become active

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [August 11, 2015, 10:18am UTC](https://forum.juce.com/t/mouselistener-callbacks-dont-work-unless-the-editor-or-a-subview-has-received-one-click/15292/5 "2015-08-11T10:18:52Z")

</div>

In apps, I have a few tricks in JUCE that let the GUIs handle mouse-moves before the windows get focused, but that sort of hackery isn't available in plugins, so the windows have to behave in the way the OS/host makes them.

---

<div class="post-metadata">

**Author:** ![Zoabis](https://avatars.discourse-cdn.com/v4/letter/z/46a35a/32.png) [@Zoabis](https://forum.juce.com/u/Zoabis)\
**Post date:** [August 11, 2015, 10:22am UTC](https://forum.juce.com/t/mouselistener-callbacks-dont-work-unless-the-editor-or-a-subview-has-received-one-click/15292/6 "2015-08-11T10:22:49Z")

</div>

When I open the GUI in Ableton, it doesn't have focus, then when I click the grey bar above my plugin, it DOES have focus but still those callbacks don't trigger until I actually make a click on the GUI (not the grey bar)

&nbsp;

I'll take a look at the Audio plugin demo and see what I'm doing differently&nbsp;

---

<div class="post-metadata">

**Author:** ![Zoabis](https://avatars.discourse-cdn.com/v4/letter/z/46a35a/32.png) [@Zoabis](https://forum.juce.com/u/Zoabis)\
**Post date:** [August 11, 2015, 10:31am UTC](https://forum.juce.com/t/mouselistener-callbacks-dont-work-unless-the-editor-or-a-subview-has-received-one-click/15292/7 "2015-08-11T10:31:00Z")

</div>

ok, the callback works in JuceDemoPlugin so I must be doing soemthing wrong. &nbsp;I'll look at my code.

Thanks

Dave

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![matkatmusic](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@matkatmusic](https://forum.juce.com/u/matkatmusic)\
**Post date:** [August 11, 2015, 10:34am UTC](https://forum.juce.com/t/mouselistener-callbacks-dont-work-unless-the-editor-or-a-subview-has-received-one-click/15292/8 "2015-08-11T10:34:06Z")

</div>

I believe that the titlebar for the window isn't part of the content component, which is where the mouseEvents listeners are responsive. &nbsp;perhaps that's the problem? &nbsp;

Maybe the titlebar has focus, as opposed to the content component, and clicking on the content component changes the focus, which turns on the event listeners. &nbsp; I'm just guessing tho.. &nbsp;

---

<div class="post-metadata">

**Author:** ![Zoabis](https://avatars.discourse-cdn.com/v4/letter/z/46a35a/32.png) [@Zoabis](https://forum.juce.com/u/Zoabis)\
**Post date:** [August 11, 2015, 10:42am UTC](https://forum.juce.com/t/mouselistener-callbacks-dont-work-unless-the-editor-or-a-subview-has-received-one-click/15292/9 "2015-08-11T10:42:31Z")

</div>

Hi matkatmusic.

Well, for Jules's JuceDemoPlugin it works. &nbsp;I mean, I added:

&nbsp;

void JuceDemoPluginAudioProcessorEditor::mouseMove (const MouseEvent& e)

&nbsp;

and the callbacks happen even if I only click the bar at the top. Also, I just noticed the keys on the midi keyboard light up as I hover over them on the Demo but in my plugin, that only happens after I click once on the GUI!!

&nbsp;

Very weird

&nbsp;

---

<div class="post-metadata">

**Author:** ![ckk](https://avatars.discourse-cdn.com/v4/letter/c/d26b3c/32.png) [@ckk](https://forum.juce.com/u/ckk)\
**Post date:** [August 11, 2015, 10:48am UTC](https://forum.juce.com/t/mouselistener-callbacks-dont-work-unless-the-editor-or-a-subview-has-received-one-click/15292/10 "2015-08-11T10:48:03Z")

</div>

Did you set “Plugin Editor requires Keyboard Focus” in Introjucer?  
You might also need to add setWantsKeyboardFocus(true) in your PluginEditor component?

---

<div class="post-metadata">

**Author:** ![Zoabis](https://avatars.discourse-cdn.com/v4/letter/z/46a35a/32.png) [@Zoabis](https://forum.juce.com/u/Zoabis)\
**Post date:** [August 11, 2015, 10:55am UTC](https://forum.juce.com/t/mouselistener-callbacks-dont-work-unless-the-editor-or-a-subview-has-received-one-click/15292/11 "2015-08-11T10:55:19Z")

</div>

Hi ckk,

I hadn't set that but I looked and Jules has set that for the demo so I'll try that. &nbsp;I'm busy with somehting for half an hour but I'll report back once I've checked that out

&nbsp;

Dave&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Zoabis](https://avatars.discourse-cdn.com/v4/letter/z/46a35a/32.png) [@Zoabis](https://forum.juce.com/u/Zoabis)\
**Post date:** [August 11, 2015, 11:08am UTC](https://forum.juce.com/t/mouselistener-callbacks-dont-work-unless-the-editor-or-a-subview-has-received-one-click/15292/12 "2015-08-11T11:08:38Z")

</div>

Just had to click 'Plugin editor requires keybaord focus' in the Introjucer and all is well.

Cheers ckk!
