psychopy.org | Reference | Downloads | Github

Click not Ending Routine on Pavlovia

In builder (v3.2.3), I set a routine to end when a mouse click occurs on an image. When I synced the experiment to Pavlovia, nothing happens when I click on the image.

I have already tried the following fixes:

  1. Add a transparent polygon over the image, and add it to valid clicks.

2)Added the following code, to directly insert a code component:

<CodeComponent name="consentcode">
        <Param name="Begin Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin JS Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="Code Type" updates="None" val="Py" valType="str"/>
        <Param name="Each Frame" updates="constant" val="if (consent.isPressedIn(agreeimage)) {$amp;#10     continueRoutine = false;&amp;#10    }" valType="extendedCode"/>
        <Param name="Each JS Frame" updates="constant" val="" valType="extendedCode"/>
        <Param name="End Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="End JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="End JS Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="End Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="name" updates="None" val="consentcode" valType="code"/>
      </CodeComponent>

None of the above have worked, so I’m at a bit of a loss.

Hi @cello98, looks like you have not translated the Python code to JavaScript. In your code component, set a code type of “both” and translate the Python (left) into JavaScript (right). E.g.,:

if (agreeimage.contains(mouse.getPos()) && mouse.getPressed()[0] === 1) {
    continueRoutine = false;
}  

I tried this, but now the routine before (which I did not alter in any way) just freezes and doesn’t proceed to the next routine.

Would you mind sharing the URL so I can help debug?

Original problem routine is P3, new problem routine is P2.

Thanks, it looks like you have several psyexp files in that repo. Which one should I be looking at?

ExpHillsdale.psyexp

Ah, it turns out that you do not even need code. You can set your mouse to only end the routine on valid clicks, and set the image as a clickable stimuli in your mouse. This way, only valid clicks (on your button) will end the routine and move on to the next routine. This is what you have done in your Qsex_2 routine, so just copy that set up.

By the way, I see you are using the Form component. This is not currently supported in online studies, so you will not see the Form written to your online task. However, you could recreate the Form using multiple sliders and text components, which is what the Form essentially is.

Thanks for the heads up regarding the form component. Regarding the mouse issue, I had originally set it up to end the routine on a valid click (which worked fine offline), but when I uploaded originally, it didn’t work, so I tried direct coding instead. I tried it again to be sure, and that’s still not working.

Have you actually set the mouse the end the routine on “valid click”? It was set to “never” previously. Also, I have just tried this, and it is working. Can you also try refreshing your browser cache to make sure the most recent changes have been downloaded?

Turns out the real problem was that I was trying to run the experiment on Safari. It works as desired on Google Chrome.

1 Like