Hello,
I am brand new to python and PsychoPy, so I apologize in advance for my current limited knowledge.
I am trying to code so that a person can drag squares and drop them in a central location to create a picture. If I drag the first square there are no issues. If I drag the second square, when it moves over the first, the second square is dropped and the mouse picks up the first square. The same happens when I move square 3 over squares 1 and 2.
I’ve tried:
if (mouse_resp.isPressedIn(square, buttons=[0])):
square.setPos(mouse_resp.getPos()) # set the image where the cursor is
squareTx, squareTy = mouse_resp.getPos()
# counterMoves += 1
if (mouse_resp.isPressedIn(square1, buttons=[0])):
square1.setPos(mouse_resp.getPos()) # set the image where the cursor is
bsquare1Tx, bsquare1Ty = mouse_resp.getPos()
if (mouse_resp.isPressedIn(square2, buttons=[0])):
square2.setPos(mouse_resp.getPos())
square2Tx, square2Ty = mouse_resp.getPos()
I’ve also tried the above with if, elif and else. I’ve also tried:
if (mouse_resp.isPressedIn(square, buttons=[0])
and not mouse_resp.isPressedIn(square1, buttons=[0])
and not mouse_resp.isPressedIn(square2, buttons=[0])):
square.setPos(mouse_resp.getPos()) # set the image where the cursor is
squareTx, squareTy = mouse_resp.getPos()
# counterMoves += 1
elif (mouse_resp.isPressedIn(square1, buttons=[0])
and not mouse_resp.isPressedIn(square, buttons=[0])
and not mouse_resp.isPressedIn(square2, buttons=[0])):
square1.setPos(mouse_resp.getPos()) # set the image where the cursor is
square1Tx, square1Ty = mouse_resp.getPos()
else (mouse_resp.isPressedIn(square2, buttons=[0])
and not mouse_resp.isPressedIn(square, buttons=[0])
and not mouse_resp.isPressedIn(square1, buttons=[0])):
square2.setPos(mouse_resp.getPos())
square2Tx, square2Ty = mouse_resp.getPos()
What do I need to add so that it doesn’t switch to a “higher” square while a lower one is being dragged over a “higher” one?
Thank you very much for your help with this.
Kym