Trackpad right-button key modifier?

I am trying to add a “right click” popup menu to a button, and while isPopupMenu works with a mouse (right-click) and with control-click (on mac), it doesn’t work with the “two-finger tap” of my MacBook’s trackpad.

Isn’t the two-finger tap supposed to be right-click? it is for every app on the Mac… How can I intercept the two-finger tap to add it as a modifier?

Could you provide a minimal example that demonstrates the issue. I’ve never had any problem with “two-finger tap” on a Mac.

So apologies if my code is choppy, still learning…

I have a drawable button, onClick I send a DBG message, if isPopupMenu, I send an extra DBG message, on mac, two-finger tap doesnt work, but CTRL+click works fine.

   midiButton->onClick = [this] {
        DBG("lal");
        if (juce::ModifierKeys::getCurrentModifiers().isPopupMenu())
            DBG("lol");
    };

Hmm, something funky going on here that may well be a bug.

100% sure that testing MouseEvent.mods.isPopupMenu() in mouseDown or mouseUp methods of a Component (or derived class) works as intended, but I never used onClick beyond implementing left click behaviours.

Looking quickly at the JUCE code seems like this should work in onClick for a Button, but I don’t have time to investigate further.

OK SO I just used the MouseDown method and I confirm it works correctly, meaning the onClick must have a bug

void mouseDown(const juce::MouseEvent& e)
{
    if (e.eventComponent==midiButton.get())
        if (e.mods.isPopupMenu())
            DBG("lol");
}

So just an “etiquette” question, since onClick is buggy, should I just always stick to listeners and mouseDown, or should I use onClick for left clicks and mouseDown for the rest?

Please be aware that adding a MouseListener for intercepting the right mouse click is only half of the problem: the Button that you right-clicked will still perform its action exactly as if it were left-clicked, and that may not be what you wanted/your user expects when right-clicking to display its context menu.

To prevent the left-click action being triggered when right-clicking, there are a number of workarounds (listed in the topic linked below), but IMHO it would be better for JUCE Buttons to natively have an option to ignore right-clicks (or hey, even provide a onRightClick lambda for them, that would be awesome) so if you agree, please cast your vote in the Feature Request topic linked below, perhaps that will catch the JUCE team attention…

1 Like

This right click disparity has not yet been addressed, and it needs to be. On a modern Macbook or MBP, right click DEFAULTS to cmd-click for system right click. The user needs to activate the two-finger right click (which is the right click that JUCE recognizes) in trackpad settings.

I shouldn’t have to add a special case for cmd-click-if-you’re-on-a-Mac-with-a-trackpad.

Note this also happens if the user has a Magic Mouse connected, as it also defaults to cmd-Click for right click.

Fucking Apple.