BART, online, pavlovia

Hi @lorenzo.brienza,

I think the code is inflating nPumps for the duration that the mouse is pressed, instead of only once per “click”. You can add additional code to keep track of mouse state to avoid this behaviour. Something like the following should do the trick:

In Begin Routine

mouse.clickReset() #resets mouse state
mouseup = True #the mouse is not clicked yet

In Each Frame

if mouseup and 1 in mouse.getPressed(): #mouse must change from "up" to "down" i.e. a "click"
        mouseup = False #mouse is now down

        if mouse.isPressedIn(LOCATION_1):
            #DO STUFF
        elif mouse.isPressedIn(LOCATION_2):
            #DO SOMETHING ELSE

        
else: #mouse is being held down
    if not 1 in mouse.getPressed(): # mouse button has been released
        mouseup = True

I tested this in PsychoPy 2022.2.4. Other versions may behave differently.

-shabkr

1 Like