Mouse click on object error in Pavlovia but good on local PsychoPy

URL of experiment: test1 [PsychoPy]

Description of the problem:
I tried to set two texts for mouse clicks, and it didn’t work. So I used two squares in the back. It worked but once I chose to store the click (no matter what), it will not be able to run on Pavlovia.
Screenshot 2024-03-04 at 12.05.33 AM

Error code:
Unfortunately we encountered the following error:

  • TypeError: obj.contains is not a function
    Try to run the experiment again. If the error persists, contact the experiment designer.

I’m having the same issue

More information is needed, but here’s one solution.

1 Like

I read that thread but I’m not sure how to implement these changes in the builder.
Here is my code, the commented line is where the error occurs

type or paste code here
// check whether click was in correct object
          if (gotValidClick) {
              corr = 0;
              corrAns = corrans;
              for (let obj of [corrAns]) {
               // if (obj.contains(mouse_5)) {
                      corr = 1;
                  };
              };

Are you using a variable as the clickable stimulus for your mouse component?

What does it look like?

What version of PsychoPy are you using?

Yes, I’m using other object components as the clickable stimulus. I’m using verion 2024.1.1


Correct answers for mouse components don’t yet work online

Oh ok, is there a workaround?

I changed the experiment so the only clickable stimuli is the correct answer, but I’m still getting the same error:

type or paste code here
for (const obj of [corrans]) {
            if (obj.contains(mouse_5)) {
              gotValidClick = true;
              mouse_5.clicked_name.push(obj.name)
            }
          }

I tried adding “…” in front of the variable in the “Clickable stimuli” field, but I’m still seeing the same error.

Are you seeing the latest code? Check an incognito tab.

My workaround would be to allow all objects to be clicked without ending the routine and then check the clicked_name in Each Frame.

if mouse_5.clicked_name:
     if corrans in mouse_5.clicked_name:
          continueRoutine = False:

Thank you, it works now.