Popup Menu Issues in OS X

Hi, I’m new here – thanks a ton for the work you’re doing with JUCE!

There are several topics about PopUp Menu issues, but I haven’t seen this particular issue mentioned. Note: after testing on both Windows and OS X, I can confirm that the buggy behavior only occurs on OS X.

In void mouseDown( const MouseEvent& event ) callback of a Component, the PopUp Menu example from the documentation works fine. If, however, the same exact code is wrapped in an if ( event.mods.isRightKeyPressed() ) scope, the resulting menu flashes and disappears.

This is the bit of code that causes problems (tested in a blank GUI Application created with ProJucer):

void MainContentComponent::mouseDown (const MouseEvent& event)
    if (event.mods.isRightButtonDown()) {
        PopupMenu menu;
        menu.addItem (1, "Deactivate Track");
        menu.addItem (2, "Delete Track");
        auto result = menu.show();
        DBG ("result of the menu thing is " << result);

And if you comment out the if, the menu doesn’t flash out of existence on next frame – works as expected.

System Info:
MacBook Pro (Retina, 15-inch, Mid 2015); OS X 10.11.4
Xcode Version 7.3 (7D175)

JUCE version:
$ git describe --long --tags

Any advice on a better way of handling this issue would be much appreciated :slight_smile:

you probably need to override the other mouseEvents as I bet they are being fired as well. stuff like MouseMove gets triggered when you scroll the mousewheel, which was super annoying behavior when I discovered it…

I tried adding that code to a random component and it worked just fine. Must be something else going on in your code that’s cancelling it, I guess.

Jules: thanks a lot for a fast response! I’m going to jump at this opportunity for thanking you for JUCE in person. A lovely thing to use and a lovely thing to learn from – thanks, man!

I’ve tested this with a brand new GUI Application created by ProJuicer, where I just added the code I provided to the MainComponent – did you try with a mouse or the trackpad? Could be that the issue is with double-finger-right-click, since replacing the predicate with event.mods.isCommandDown() operates correctly. I did just try with an ancient USB Mouse we have laying around in the lab, and the problem persists, but very rarely leading to the menu remaining open. In most cases, it just flashes out of existence & outputs a zero.

If you can not get this to repro, I’ll make a video for my own sanity, but first I will try debugging this by stepping into everything… Thanks!

Thanks! But no, I can’t reproduce this. Maybe put a breakpoint in the code inside PopupMenu that dismisses it and you should be able to see what the event is that’s causing the menu to go away. If you’re using weird mouse gestures then maybe your driver is actually sending multiple click events or something.