Jump to content
Sign in to follow this  

Detecting Mouse Click versus Mouse-Click-Drag

Recommended Posts


As with most applications, I have the left mouse button initiate clicks on objects as well as moving those same objects. The problem is detecting a mouse click versus a mouse-click-and-drag.

Here is what I have done - it works but it is clunky (IMO):

left click is detected, the mouse coordinates are captured and a timer is started.

in a while loop, the mouse coordinates are checked and if the mouse has moved more than 2 pixels from the start, then a drag is performed

if the timer reaches a set time ~80-100 ms, then a click is performed

The issue is the delay between click initiated and performed is 80-100 ms and might be more on other systems. I was curious if there is a better more efficient way to detect the two events?

You can't see a rainbow without first experiencing the rain.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.