Lagging while clicking and dragging

Hi there,

I am a beginner and following some useful tutorials on the site. I encounter an issue during the tutorial below. I use a mouse to click and drag quickly and object on the screen, but it doesn’t move with the cursor. I have to move slowly enough for the mouse cursor and the object to move synchronously. I am designing a protocol while being able to move an object quickly on screen is key. So, I hope this can be fixed.

https://peterscarfe.com/mouseContingentSquare.html

I looked it up and the mouse polling speed can contribute, but I don’t think that is an issue as I don’t run into this issue on other programs. The issue seems to be having to check if the mouse is clicking in the code. I tried to allow the object to move with the cursor, after clicking and then releasing the mouse button. The tracking works smoothly and has no lagging. Unfortunately, that is not going to work in my experimental protocol.

Please help and thank you very much in advance.

Best regards,
Teerawat

I have just uploaded a new version of the code that allows fast mouse movements. As far as I can see, the issue was that you can move the mouse very quickly relative to the typical refresh rate of a computer screen, so the “inside” cue would report 0 (correctly). As such the square would no longer be yoked to the mouse.

In the new code the check for “inside” is only done once, until that is, the mouse is released. When the mouse is released it will continue to check again.

Peter

1 Like