Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Help me ,immediately !!!!

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!!
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.
Posts: 15870
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Bookmark Topic Watch Topic
  • New Topic