Double click detection
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!"
// Tojiart
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
Magmai Kai Holmlor
- Not For Rent
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
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!"
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!"
// Tojiart
July 24, 2001 05:27 AM
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement