PopupMenu::CustomComponent mouse event problem OS X 10.8

The custom popup menu component isn’t getting any events except when a click happens. I tried putting a mouseMove function in the CustomMenuComponent class in the Juce Demo and it never gets triggered unless I click on the component. The behaviour is correct on windows.

It’s not just 10.8. I was able to reproduce this in 10.7 as well. So it probably happening on all OS X. The code works fine on Windows though.

To reproduce simply put:

at Line 186 of extras/JuceDemo/Source/demos/WidgetsDemo.cpp

Well OSX behaves differently from windows - non-active windows don’t get sent mouse-moves. And when you have a menu, it doesn’t become the active window, because it’s only temporary. So the OS doesn’t actually send it any mouse-moves.

Inside the popup menu code, I work around this with a global mouse listener and timer, but it won’t magically create events for custom components, you’d need to use a similar workaround yourself for that.

[ignore post...found solution]

 

But, from PopupMenu, this looks wrong:

Appends a custom menu item that can't be used to trigger a result.

This will add a user-defined component to use as a menu item. It's the caller's responsibility to delete the component that is passed-in when it's no longer needed after the menu has been hidden.

If triggerMenuItemAutomaticallyWhenClicked is true, the menu itself will handle detection of a mouse-click on your component, and use that to trigger the menu ID specified in itemResultID. If this is false, the menu item can't be triggered, so itemResultID is not used.

See Also 

CustomComponent

 

It might want to read: 

This will add a user-defined component to use as a menu item.

It's the caller's responsibility to delete the component that is passed-in when it's no longer needed after the menu has been hidden.

On some platforms normal Mouse callbacks are not available in PopupMenus.  So use @see PopupMenu::CustomComponent as a base for your custom component which provides methods that can be used instead for mouseOver highlighting. 

If triggerMenuItemAutomaticallyWhenClicked is true, the menu itself will handle detection of a mouse-click on your component, and use that to trigger the menu ID specified in itemResultID.

Otherwise a method from PopupMenu::CustomComponents can be used to trigger the menu item. 

Ah - no bloody hell.  

I missed it right at the bottom after all.  Ignore that too: 

addCustomItem has an override!

Maybe the other addCustomItem should have an @see addCustomItem (2) pretty near the top ;-)

It's all very confusing. I'm going to get a coffee.