Right-click with trackpad


#1

Hi,

I primarily develop with a mouse (duh), but every once in a while I find myself working away on the laptop in a coffee shop without a mouse…

It seems that most apps interpret a Ctrl+Click as a Right-Click. JUCE doesn’t seem to do this…
Unfortunately, certain parts of my app are relying on right-clicking, and I’m checking the MouseEvent’s ‘mods’ for isRightButtonDown(). With a two-button mouse, this obviously works… with a trackpad and the Ctrl key, it doesn’t.

I checked out the JUCE demo, and right-clicking a slider opens a popup menu. This, however, is checking e.mods.isPopupMenu()…
Should I be using that instead of right-click? Seems a bit odd…

thanks


#2

yes, that is exactly what you should be doing.

check the docs for the mouse event; they point out that ‘isPopupMenu’ is what you should really be using if you want cross platform ‘rightmouse button’ support.

‘isRightButtonDown’ should only return true if the right button is down. CTRL+Click is NOT the right mouse button, and so it should not return true for that! How would the windows platform discern the difference between them?

‘isPopupMenu’ checks for right button OR ctrl-click. It is checking for a particular context, rather than the literal right-button. It would be wrong to expect juce to automatically decide that ctrl-click = right button.

So you have indeed found your solution! Congratulations!


#3

Well, I think this could be argued either direction…
No, Ctrl+Click is not the right mouse button, but it does emulate the right mouse button.

There are applications that make use of the “right” button that aren’t just opening popup menus (however unintuitive that may be… but i’ve personally worked on several pro audio applications that required that functionality). I believe that by having to check “isPopupMenu” is unintuitive to the mouse-button oriented programmer who sees “isRightButtonDown” and opts to use that because, well, it makes sense at first glance.
Why not just have isRightButtonDown() call isPopupMenu() when JUCE_MAC is defined? Seems easy enough…

I’ve now “fixed” the bug on my end, do as you please.


#4

now you have understood how juce works, then go using it that way. if you just want to check mouse events the way you expect you better write applications in sdl…
isRightButtonDown means that Your Right Mouse Button Have Been Pressed, not that you triggered a PopupMenu. after all you want to catch a right button down when you pressed ctrl + something isn’t it ? isn’t that logically not-obvious ?

and yes, i’m absolutely neither a mouse-button oriented coder nor a “isRightButtonDown cause it’s easier” coder. i just share and understand the jules logic behind all this…


#5