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

Help me ,immediately !!!!  RSS feed

 
chenw
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I catch the event which the right botton and the left botton are clicked at the same time?
Thanks a lot!!
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're still going to get 2 mouse events, one for each click. You'll have to write your listener to watch for this state.
You can set up two MouseEvent variables, one for lastLeftClick and lastRightClick. WHen you get a button click event, look at the event to see which mouse button it is, then save it to the right variable. When you get another MouseEvent that's a button event, and you see if it's, say a left mouse click...then you compare the time of that event to the time of the previously saved right mouse click event, and if they are within a certain threshold time...say 100 ms, you can consider that a simultaneous left/right mouse button click.
Rob
 
Junilu Lacar
Sheriff
Posts: 10946
158
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"chenw"
Please take a moment to review the JavaRanch Naming Policy. Please re-register using a Display Name that conforms to the policy.
Thanks for your cooperation.
Junilu Lacar
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!