Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Blue*Omega

Double click detection

This topic is 6232 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, this is bugging me! How do you detect a double click? Don''t know why this would matter but: Using Microsoft C++ Using Direct Input 8 (NO! I do NOT want to use buffered data!) ----------------------------- Vash the Stampede "Love & Peace!"

Share this post


Link to post
Share on other sites
Advertisement
Everytime you get a click, store the time (and perhaps the location) and compare it to the time/pos of the previous click. If the difference is below a threshold (100ms? +/-3pixels?) it''s a double click.

Magmai Kai Holmlor
- Not For Rent

Share this post


Link to post
Share on other sites
Hmmm... Simple, yet effective. I like it! (Actually, I''m surprised I didn''t think of that before. ^_^)

I should mention for anyone else that happens to read this that you probably wouldn''t want to register a single click till after the threshold has been passed. Otherwise you would get some screwy results.

Thanks again!

-----------------------------

Vash the Stampede

"Love & Peace!"

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
There is one more issue that you should take in considiration:
If you want to take one action if you click and another if you double click. The reason that there is trouble is that you can''t take the click action right away since it might be the first click of a double click action. The solution is annoying but effective.
When you get the Click event, you start a timer with a GetDoubleClickTime() span.
If you get the timer event before a double click event, then take the click event.
If you get the double click event kill the timer and do the double click event.
One draw back that this have is a small delay after doing the click, until the action is taken. usually (unless the user set the DoubleClickTimer to a long delay) the user will not fill the delay.
-- Gilad

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!