iOS: PopupMenu::CustomComponent always results 0

Please consider the attached example. When I create a PopupMenu with CustomComponents, and use PopupMenu::Options::withParentComponent, clicking (tapping) items in the menu always gives the result 0. I’m using JUCE 5.4.3 commit ccbcc41b.

If I use non-custom menu items however, it works. Also, if I omit the withParentComponent, it works as well. It is only broken on iOS (Simulator and my iPad); on Mac it works correctly.

Minimum working example to reproduce:

CustomMenuItemTest.h (3.4 KB)

This should be fixed on develop with commit 5630241. Thanks for reporting!

1 Like

@ed95 Thanks! This also fixes some iOS-only issues I had with PopupMenu nested sub-menus.

Thanks for getting on this!

Hi @ed95 Thank you again for this fix :blush: I came across an issue with multi-touch. The change was to call the static getCurrentRawMousePosition() for touch sources, too. I’m not sure, but that seems to be a merged position, not separated by index/finger. In my case, it happens when playing with ≥ 2 fingers on a MidiKeyboardComponent.

I tried reverting the commit (ba0d687e) and instead added a check to setScreenPos:

void setScreenPos (Point<float> newScreenPos, Time time, bool forceUpdate)
    {
        if (! isDragging())
            setComponentUnderMouse (findComponentAt (newScreenPos), newScreenPos, time);

        if (newScreenPos != Point<float>(-1, -1) // Added this check
            && (newScreenPos != lastScreenPos || forceUpdate))
        {
            cancelPendingUpdate();
            lastScreenPos = newScreenPos;
            // ...

This way, if it receives {-1, -1} from the Peer, it doesn’t save that as the lastScreenPos. This seems to solve my original PopupMenu issue, while also keeping multi-touch working.
I hope that this doesn’t break anything else, but I’m not 100% sure because I’m not familiar with all the internals there.

Are you using the latest tip of the develop branch? I already added that check here

1 Like

Great, thanks! Confirming that it works as well, and I’ll use your check instead :+1: