Mulitple Mouse Components

Hi - I’m working on an online experiment involving simulated AI advisors.

In my main routine, I have a video stimuli with two buttons (A and B). A valid click on either button should end the routine. I also have button C. A valid click on C should display some text (the ‘AI’ advice), but not end the routine.

I have created two mouse components. The first has buttons A and B as clickable stimuli and is set to end routine on valid click. The second has button C as clickable stimuli and doesn’t end routine. The AI text box has a start condition: second_mouse.clicked_name==“Button C”

The first mouse component works fine - I can select button A or B and the routine ends. However, the clicking on Button C has no effect. I’ve put some print statements into the code and it looks as if the second mouse isn’t being checked for clicks at all. I suspect this is because the ‘gotValidClick’ variable in the code is common to both mouse components so only the first component is getting properly considered. However, I’m not sure how to fix it. I’ve tried recoding the script so that there are two independent ‘gotValidClick’ variables, but that doesn’t seem to work either.

My experiment needs to run online, so any code changes need to be replicable in js. I’m hoping someone else must have had experiments where one button on a screen ends a routine but another just displays a component…?

Do you really have a space in your button names?

No, sorry. I was just trying to simplify the scenario. What I’ve referred to as ‘Button A’ and ‘Button B’ are actually four components called: ‘UK_text’, ‘UK_box’, ‘US_text’, ‘US_box’

‘Button C’ is made up of four components: ‘AI_box_thinking’ and ‘AI_text_thinking’ which after 5 seconds are replaced by ‘AI_box_ready’ and ‘AI_text_ready’. On clicking either of those last two components, two more components should appear: ‘AI_box_result’ and ‘AI_text_result’

The mouse components are actually called: ‘mouse’ and ‘AI_mouse’

Hope that helps.

For the start condition, I’ve tried AI_mouse.clicked_name==“AI_box_result”; AI_mouse.clicked_name[1]==“AI_box_result”; AI_mouse.clicked_name as a Boolean.
None of these work - from what I can see, the code never even gets to the point where it’s checking for a valid click on AI_mouse

This might actually work better on Pavlovia than it does locally. The Pyglet window that PsychoPy uses when running locally just doesn’t support multiple mice, period. It will only read from the first one. However, that’s python-specific, so JS might not have this issue. If you try piloting it locally in JS, do you run into the same problems?

I did unfortunately, and when running it on Pavlovia. I’ve come up with a fix (though it isn’t very elegant!) I’ve moved the AI_mouse ‘check valid click’ code into the normal mouse code and it seems to be working. I’ve also had to add a time check in there, as for some reason it was registering clicks on AI_box_ready before that component had started. It seems to be working, but I think I can give up on making any tweaks using Builder from now on!

1 Like

I quite often use the .isPressedIn function in the Each Frame tab of a code component if I have a more complex mouse responses

1 Like

Perfect - this has worked really well (and completely removes the need for a second mouse component). Thank you!