psychopy.org | Reference | Downloads | Github

Participants change click location on graph, only record location of last click for each trial

For my experiment participants estimate a point on a graph. I currently have it so that when they click on the graph it displays an ‘x’ where they clicked and then stores the coordinates of the ‘x’. However, I want participants to be able to change their answer if they click on the wrong place on the graph. So, I would like the ‘x’ to move to wherever their most recent click is for each graph image. I would also like only the last place they click per each image to be stored in my data file.

Currently for Begin Routine I have

allText = []
clickN = 'x'
getLoc = None
addText = True

def makeText(clickN):
    return visual.TextStim(
        win, 
        text=clickN, 
        pos=getLoc, 
        depth=-2.0,
        color=[-1,-1,-1],
        height=.025)

And for each frame I have

for mouse.isPressedIn(image) 

if mouse.isPressedIn(image) and getLoc is None:
    getLoc = mouse.getPos()
    
if not mouse.isPressedIn(image) and getLoc is not None:
    allText.append(makeText(clickN))
    allText[0].setAutoDraw(True)
    clickN = 'x'
    getLoc = None

You haven’t said what it’s currently doing but it looks like you’re creating a new x for every click.

How about

makeText = visual.TextStim(
        win, 
        text=clickN, 
        pos=getLoc, 
        depth=-2.0,
        color=[-1,-1,-1],
        height=.025)

and

if mouse.isPressedIn(image) 
    getLoc = mouse.getPos()
    makeText.txt='x'
    makeText.pos=getLoc

Then in End Routine
thisExp.addData('Position',getLoc)

So currently it is creating an ‘x’ on the first click of each trial, but if you click again it doesn’t do anything. What I want is for it to move the ‘x’ if you click the same trial image a second time and only record the location of the last time the participant clicks an image. Your code didn’t show any ‘x’ when I clicked on the image.