• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help me ,immediately !!!!

 
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: 10056
120
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!