This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting Right mouse click on all platform  RSS feed

 
Sarone Thach
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
can someone tell me how to determine a right mouse click on all platforms, Mac, Linux, Windows.
I'm sure there is a generic way of getting that info.
Thanks,
Sarone
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're looking for right-clicks to do a pop-up menu, then it's pretty simple. You need to add a MouseListener (or MouseAdaptor) that checks for both "mousePressed" and "mouseReleased" actions.
In the method that handles the event, make sure you do a ".isPopupTrigger()" check. This corresponds to the right-click of a mouse, where the usual action is to pop-up a menu. You don't have to pop up the menu, but that will tell you it's a right-click.
I've noticed that on Windows this happens in the "mouseReleased" method, and on UNIX (Linux) it happens on the "mousePressed" method. But checking both you should have all your bases covered.

[ December 11, 2003: Message edited by: Wayne L Johnson ]
 
Sarone Thach
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes! exactly what I wanted! Thank you! I'm so glad I didn't have to check the mouse modifiers, as it is such a pain and is different for diff platforms.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!