Thanks for the answer, however it won’t work in my case - specifically, when I want to do stuff twice, three times, etc., WITHOUT going into elif and setting buttonPressed = False again.
I came out with this solution:
buttons, times = mouse.getPressed(getTime=True)
for square in squares:
if mouse.isPressedIn(square) and buttons[0] == 1: # left key
# do stuff, when left click
elif times[2] != 0 and buttons[2] == 1: # right key
# reset button and times
mouse.clickReset()
buttons[2] = 0
# do stuff, when right click
mouse.clickReset()
Importantly, the times are positive numbers in psychopy, but negative online on pavlovia!