Wacom right click on Mac

So with a Wacom pen, typically one of the side buttons is mapped to a right mouse click. But this isn’t working with JUCE (on Mac - on Windows it works fine).

event.mods.isRightButtonDown() is returning false.

For an example, try running the JUCE demo app, go to the Code Editor demo and try right-clicking with a mouse in the editor. A contextual menu will appear. Now try right-clicking with a Wacom pen - no menu, just a normal click.

I tracked the problem to juce_mac_NSViewComponentPeer.mm, NSViewComponentPeer::redirectMouseDown. It’s calling [NSEvent buttonNumber]. For a normal mouse, this returns 0 for left click and 1 for right click. But for a Wacom pen it always returns 0.

I’m not sure if this is a problem with JUCE, or the Wacom drivers. I have a workaround for myself in that I check both for isRightButtonDown, but then I also check if the current event type is an NSRightMouseDown event.

This is clearly an NSRightMouseDown event to the OS, and all other software recognizes the Wacom side button as a right click, so I suspect JUCE may be misusing this buttonNumber method.