Error mouse.setPos in Pavlovia

In my experiment I want the participants mouse to be set to 0,0 on each trial. I use the code mouse2.setPos([0,0]) to do this. However, when uploaded to pavlovia I get this error:

Unfortunately we encountered the following error:

  • TypeError: mouse2.setPos is not a function

Try to run the experiment again. If the error persists, contact the experiment designer."

Is there another way to set the mouse to a specific position at the beginning of the trial? The custom code doesn’t show any issues in the python to javascript translation.

Any help would be appreciated. I am using version 2022.2.5 due to several other issues in newer version I have experienced with pavlovia.

Hi bjackson55,

It looks like using code to set the position of the mouse is not possible online (there are security reasons for this, see Setting mouse position online).

Alternative solution that doesn’t require code: You could make a pre-trial routine where participants click a small button at the centre of the screen. Then their mouse will be at/near centre for the actual trial.

Hope that helps,
-shabkr

Ah I see! Thank you for sharing that. Unfortunately for this task I can’t have anything appear or be distracting between stimuli so a start button for each trial won’t work. It should be okay without resetting the mouse position. Thanks for your help!

1 Like