PopupMenu regression when triggered with Timer

Hi Jules,

I sometimes open a PopupMenu on mouseDown after a duration is reached

virtual void mouseDown(const juce::MouseEvent& e)
{
  startTimer(100);
}
virtual void timerCallback()
{
  stopTimer();

  if (!isMouseButtonDown())
    return;  
  openMenu();
}

It used to work fine.
With latest version of Juce, the menu is no more selected so I have to depressed the mouse button to be able to select something and then it reacts a bit weirdly.

Is there something I should do to fix this behavior or is something broken ?

Thanks

I don’t know… that’s a pretty subtle edge-case there, because you’re expecting the menu to start picking up the mouse events from a different component that had the mouse pressed some time ago, when it’s not even being triggered from inside the mouse-down callback… TBH if you’d asked me whether that code would work correctly, I’d have no idea without trying it. So if it did work correctly in the past, that was probably just lucky rather than something being “broken” now!

I’ve no time to debug it right now, but if you can throw me some more clues I might be able to help figure out what’s going on…

The difference with a traditional menu seems to be that mouseDrag isn’t called because Desktop::sendMouseMove() is never called
because Desktop::timerCallback() is not called.
Probably because we are already in a timerCallback() and it’s maybe no more reentrant

Maybe using an AsyncUpdater should do the trick ?

Hope this helps.

Have you tried launching the menu non-modally? (Much better to always do that anyway, of course)

nop.
It works fine with an AsyncUpdater so I guess it would be the same with a non modal menu

Well, you should definitely run it non-modally if you can. Much less opportunity for things to go wrong.