Mouse component not working properly in 2022

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10):
Mac OS 12.2.1 (intel macbook 16, 2019)

PsychoPy version (e.g. 1.84.x):

Standard Standalone? (y/n) If not then what?:y

What are you trying to achieve?:
I am trying to create a categorization experiment where participants are presented a center image stim and the have to click and drag it into 1 of 4 boxes to categorize it. I want to do this experiment online so I was hoping to try the new stimulus loading options in the newest version since I am using a large stimulus set of 1000 images. I was having trouble initially in 2022.1.1 so I downgraded to 2021.1.4 and was able to get it working. So I then tried to make the 2022 version as similar as possible. Despite the builder components looking identical, some back end processes are not working in 2022. It seems that the mouse component in 2022 is not identifying clickable stimuli. I tried using an imagestim and a transparent polygon as the clickable stim but no clicks are being registered in the log. In addition to changing the clickable stimuli I’ve tried changed the “Save mouse state” options and none resolve the issue. So I am pretty sure this is a bug.

I’ve attached the 2021.1.4 and 2022.1.1 versions as well as logs from each showing that the clickable stimuli are not working in the 2022 mouse components.

2021_log.csv (2.4 KB)
2022_log.csv (2.6 KB)
study1_categorization_mouse_2021.1.4.psyexp (24.2 KB)
study1_categorization_mouse_2022.1.1.psyexp (24.2 KB)

Do you have more detailed error information to show me

It doesn’t produce an error, the click is not registered. In the 2022 version, my output shows empty arrays for mouse.clicked_name although the clickable stimuli were clicked upon, e.g.,

For the 2021.1.4 version, the clickable stimuli are registered:

I think you misunderstood mouse. Clicked name, which stands for getting the component name.

The right thing to do is:

hope that can help you!

I see that you were running v. 2021.2.2. If I create a simple example using exactly the same parameters you show in the screenshot but in v. 2022.1.1, the mouse is not functioning properly. After some additional troubleshooting with the logs, I’ve discovered that the issue is that in v.2022 the mouse position is not being recorded correctly. My image is being presented in the center, but if I click there nothing happens. So I started clicking all over and when I clicked in the top right corner of the screen my trials were terminating properly. Checking the output .csv I see that clicking in the top right is being detected as a click in the center image, and clicking below that is logged as bottom left. The .csv reports x and y coordinates that match the locations of these images:

start_mouse.x start_mouse.y start_mouse.leftButton start_mouse.midButton start_mouse.rightButton start_mouse.clicked_name
-0.1008929 -0.0901786 1 0 0 image
-0.4339286 -0.1285714 1 0 0 bot_left
-0.4303571 -0.1241071 1 0 0 bot_left
-0.2410714 -0.1366071 1 0 0 image
-0.2410714 -0.1375 1 0 0 image

The log reports the mouse position in pixel coordinates and the clicked locations that triggered and end routine are clearly in the right of the screen despite the csv reporting a center image click.
> 20.1159 DATA Mouse: Left button up, pos=(1679,1019)
> 21.0299 EXP New trial (rep=1, index=0): None
> 22.9158 DATA Mouse: Left button down, pos=(1306,976)
> 23.0650 DATA Mouse: Left button up, pos=(1306,976)
> 23.9303 EXP New trial (rep=2, index=0): None

Next, I inserted code to get the mouse position at the start and end of the routine, and I used setPos to put the cursor at 0,0 at the start of every trial. Again, the positions are not correct as the cursor is showing up at 0,0 but is not reported here. I’m not sure, but I think -.8,-.5 in height units is the bottom left corner, which in pixel space is 0,0.

starting: [-0.8 -0.5]
ending: [-0.20535715 -0.11428571]
starting: [-0.8 -0.5]
ending: [-0.14285715 -0.4419643 ]
starting: [-0.8 -0.5]
ending: [-0.14107142 -0.5089286 ]
starting: [-0.8 -0.5]
ending: [-0.26875 -0.17678571]
starting: [-0.8 -0.5]
ending: [-0.34553573 -0.5339286 ]

This isn’t an artifact of using setPos, because the issue remains when I don’t use it. Here are the positions when I made all clicks in the right half of the screen in order to end the trials:
starting: [-1.0955358 -0.42232144]
ending: [-0.21160714 -0.13125 ]
starting: [-0.21160714 -0.13125 ]
ending: [-0.27767858 -0.46696427]
starting: [-0.27767858 -0.46696427]
ending: [-0.5 -0.525]
starting: [-0.5 -0.525]
ending: [-0.29910713 -0.27321428]
starting: [-0.29910713 -0.27321428]
ending: [-0.22678572 -0.16785714]

As a further test I ran the demo using version 2021.1.4 (which worked for my actual experiment) and the problem is not present. Here are the start and end positions when I click on the center, top left, bottom left, bottom right, and then top right images. Each click resulted in a end routine and I confirmed in the csv that the correct images are being logged.

starting: [-0.11339286 0.27857143]
ending: [-0.00625 -0.00982143]
starting: [-0.00625 -0.00982143]
ending: [-0.3 0.34285714]
starting: [-0.32678571 0.11517857]
ending: [-0.34821429 -0.25714286]
starting: [-0.34732143 -0.25803571]
ending: [ 0.28571429 -0.26785714]
starting: [ 0.28571429 -0.26785714]
ending: [0.32678571 0.30178571]

and the csv showing the correct responses being registered:

start_mouse.x start_mouse.y start_mouse.leftButton start_mouse.midButton start_mouse.rightButton start_mouse.clicked_name
-0.00625 -0.0098214 1 0 0 image
-0.3 0.34285714 1 0 0 top_left
-0.3482143 -0.2571429 1 0 0 bot_left
0.28571429 -0.2678571 1 0 0 bot_right
0.32678571 0.30178571 1 0 0 top_right

I have a linux machine that I can test this on next. But perhaps someone can try running the attached example in 2022.1.1. on a PC to see if the issue replicates.

mouse_click_demo.psyexp (20.4 KB)

I wasn’t able to get 2022.1.1 working on ubuntu, but I tested this morning on a PC and the issue wasn’t present. So this appears to be a mac specific bug.

It may be an issue with certain mac OS - this isn’t an issue on my Mac Mini (OS Big Sur 11.6.4, 2018, with an HP monitor) but it is an issue with Mac OS Mojave 10.14.6 (on both an iMac, Retina 4K, 2017 and a Macbook Pro, 2016)

I came across this on the office Mac the other day - the issue is specific to retina displays (hence why you’re getting it on only some Macs) when window type is glfw. In Preferences, you can change your window type to Pygame or Pyglet, which don’t have this problem, so I recommend doing this for a quick fix. We have a long-term solution in place for the next bug fix release (2022.1.2)

Unfortunately this didn’t seem to be the case for me. My preferences were/are set to pyglet. I confirmed that the python script is using wintype='pyglet'. glfw was not functional actually, and pygame wasn’t installed - Using a standalone installation. Having confirmed it works on a PC I can finish the script on the PC to get it running online. Thanks for the help regardless!

1 Like

I can confirm that the problem doesn’t seem to be limited to window type glfw for me either - my preferences are also set to pyglet. I do need to get my script running on our lab iMac with a retina screen, so if anyone has another quick fix we could use before the next release, please let me know!

I am using the 2022.1.2 update (first time using PsychoPy) and I have the same problem as described. I also have a Mac with Retina display.

Has any solution been released for this bug yet?

I don’t use mac and the mouse clicking is not working properly on Pavlovia. It only works if I click below the text that was supposed to be clicked.

For those experiencing this issue on 2022.1.2 when running experiments locally, try updating to 2022.1.3 - there is a bug fix in that release for an issue with mouse input which was affecting Mac users on local experiments, which may be the issue which you were experiencing (it’s a different one to the glfw issue)

@Amanda_Rocha, if you’re experiencing this running online it will be a different issue, as experiments online use PsychoJS, a different library than is used locally (PsychoPy). For the sake of keeping the forum easy to navigate, could you make a new thread? The first thing to check with your bug is: Is the text to be clicked on a :text: Text component or a :textbox: TextBox component?

yes, it is in a Text component.

I have the same problem with the mouse click, no problem in windows, but does not work with Apple Bigsur on macbook pro . even with version 2022.1.3