psychopy.org | Reference | Downloads | Github

Setting mouse position online

Hi all,

I’m trying to get the mouse cursor to return to the centre of the screen after each loop in my online experiment. Offline / locally, I’ve used the following in a (Builder) code component to achieve this:

mouse = event.Mouse()
mouse.setPos((0, 0))

but this doesn’t seem to work online. I get the error:

  • TypeError: Cannot read property ‘Mouse’ of undefined

Any guidance would be appreciated!

Hi @Jamie, yes if you would want to create a mouse object in JavaScript, you would have to add something like the following:

mouse = new core.Mouse({
    win: psychoJS.window,
  });

The thing is, I do not see anywhere in the PsychJS code that allows you to reset the mouse position. I will add this as an issue on GitHub - see:

My sense (after a quick google) is that this isn’t possible in JS, and could be a nightmare if it were (advertisers stealing your mouse to “encourage” clicking on particular buttons).

While we try to mimic the Python engine as much as possible some things will never be quite the same in browser studies.

1 Like

Thanks Jon, will close the issue on GitHub

Quick follow up since this conversation is over a year old - the setPos Command (or any other comand to manipulate the position of the mouse) is still not possible in psychoJS for online experiments, or?

6 Likes

I’m following this topic. Any news? @jon

Hi there! Still can’t reset position as far as I am aware I am afraid, will need to get participants to move their mouse to a location to start the trial

1 Like

Actually, as I tried to get across above, I would be surprised if this is ever possible because browsers making that possible will be a disaster for malicious websites that want you to click on certain things.

1 Like