Logging mouse click locations

Hi Jon,

.getPressed() is True for the duration of a mouse click, which will often last longer than one screen refresh. So you need to keep track of the first time you detect the mouse press, and then when it is no longer pressed. Only store the position and retain time on the first detection. After it is released, you start looking for a fresh press.

.clickReset() jus resets the timer associated with the mouse (for measuring reaction times). It doesn’t stop the mouse button being detected as down.

e.g. something like this (not tested):

mouse_down_detected = False

for frame in range(time_window):

    mouse_click = myMouse.getPressed()

    if mouse_click[0]: # button 0 is pressed
        if not mouse_down_detected: # initial detection
            mouse_loc = myMouse.getPos()
            mouse_click_locations.append(mouse_loc)
            mouse_down_detected = True
    else:
        mouse_down_detected = False

    some_stimuli.draw()
    win.flip()

1 Like