Mouse isPressedIn no longer registering

I sincerely apologize in advance if this question has been answered already, I attempted to do some searches but haven’t found the issue. I have code for two tasks, both of which rely on code of the type below which capture clicks within objects. This code worked over the summer, and now I’ve come back to it and it seems that that’s no longer the case.

The crux of the issue is that clicks on images are not captured, only clicks within a smaller rectangular region which seems to be centered on the center-point of the screen can advance the code. Previously, clicks were captured just fine. Any thoughts on what this might be (even if it’s something really silly, which is what I’m afraid of) would be much welcomed! The size of the images seems to have something to do with the size of the area that clicks are registered in (increasing the size of images increases the size of this area that captures clicks). I have some messages on the Console that I thought might be relevant about a Gestalt selector, code signing, and CarbonCore, but I’m not sure if they’re at all pertinent. A shortened code section is below.

for tidx, trial in enumerate(trials):
        #Set values for trial
        img1.setImage(trial['path1'])
        img2.setImage(trial['path2'])
        img3.setImage(trial['path3'])

        onset = globalClock.getTime()
        trials.addData('onset', onset)
        correct=None
        responses=None
        key=None
        rt=None
        Pressed=False
while not Pressed:
            img1.draw()
            img2.draw()
            img3.draw()
            resp_prompt1.draw()
            win.flip()

            key=event.getKeys(keyList=('escape'))
            mouseclick1=mymouse.isPressedIn(img1)
            mouseclick2=mymouse.isPressedIn(img2)
            mouseclick3=mymouse.isPressedIn(img3)
            if mouseclick1 or mouseclick2 or mouseclick3:
                rt=globalClock.getTime()-onset
                if (mouseclick1==True and trial['Key']==1):
                    correct=1
                    core.wait(.1)
                    Pressed= True
                    event.clearEvents()
                elif (mouseclick2==True and trial['Key']==2):
                    correct=1
                    core.wait(.1)
                    Pressed= True
                    event.clearEvents()
                elif (mouseclick3==True and trial['Key']==3):
                    correct=1
                    core.wait(.1)
                    Pressed= True
                    event.clearEvents()
                else:
                    correct=0
                    core.wait(.1)
                    Pressed= True
                    event.clearEvents()
            elif 'escape' in key:
                logging.flush() # if you are using logger
                win.close()
                core.quit()
                break

trials.addData('resp',responses)
        trials.addData('rt',rt)
        trials.addData('correct',correct)

    logging.log(level=logging.DATA, msg="*** END OMOT ****")

    trials.extraInfo['END']=globalClock.getTime()
    trials.saveAsWideText(fileName=logname, delim=',', appendFile=False)

Hi @utooley, it would be useful if you could do some debugging with print statements. To start, you could use print statements to make sure your conditional statements are satisfied. E.g.,

mouseclick1=mymouse.isPressedIn(img1)
mouseclick2=mymouse.isPressedIn(img2)
mouseclick3=mymouse.isPressedIn(img3)

if mouseclick1 or mouseclick2 or mouseclick3:
    print(mouseclick1)
    print(mouseclick2)
    print(mouseclick3)

1 Like

Hi @dvbridges,

Thanks for the suggestion! I did try that out, but unfortunately, it seems like this bug occurs only on my Mac OS X 10.11 El Capitan PsychoPy install–I’m working on my work machine, a 10.13.6 running High Sierra and a newly installed Psychopy into Anaconda, and the clicks are captured perfectly, so I haven’t been able to troubleshoot further. Maybe the fact that it occurs on one machine and not the other is informative, though?

More updates to come if I figure it out.

Best,
Ursula

1 Like