Unable to hide mouse pointer consistently

OS Window 10 and Windows 7
PsychoPy version V2021.1.2
Standard Standalone? (y/n) Yes
What are you trying to achieve?:
Trying to hide the mouse during routines

What did you try to make it work?:
1 - I made sure the Show mouse check box in the screen settings was unchecked, and then I put
win.mouseVisible = False
in the begin routine tab of a code component before the trial loop began.
2 - I put in a mouse component named “mouse” which the win.mouseVisible = False could act upon
3 - I put it in each routine within the loop.
4 - under the Begin Experiment tab I put: from psychopy import core
under the Begin Routine tab I put: event.Mouse(visible=False)

What specifically went wrong when you tried that?:
No errors but the mouse becomes visible when the trial loop begins and remains visible for the rest of the experiment.

Oddly it did work almost perfectly once (Windows 10) with the first solution. The mouse only appeared for the first routine in the loop and then disappeared for the remainder of the experiment. However on the next execution of the task the mouse was back.

The first solution works perfectly in other experiments.

Another bit of information that might help is that on the Windows 7 machine the desktop task bar also appears at the bottom of the screen when the trial loop begins. This will disappear if the mouse is clicked, but the mouse remains visible. To prevent this I tried restarting the windows file explorer process but the taskbar is still popping up.

Thanks for any insight you can offer.

Anthony

I guess this means that you haven’t set the window to be full-screen in the experiment settings. Otherwise you can click on to other windows or parts of the operating and what you’re actually seeing is the mouse responding to those. For performance reasons, we almost always want to have the window set to be full screen anyway.

@Michael Thank you for your reply, however my task is set to full screen so this can not be the cause. I did test it once in a reduced window size before putting it back to full screen, but the mouse behaviour that I described was present before I did the reduced window size test. Can you see any other reason for this mouse behaviour, or is there some other method I could use to hide the mouse?

This is not necessary - win.mouseVisible = False is a method entirely of the Window class, no Mouse object is required. Having a mouse is likely part of the problem.

The core module has no relationship to the mouse, and this import is done automatically in all Builder scripts anyway, so this line can also be deleted.

Not necessary, and again will just unnecessarily create a transient mouse object.

It does look from my testing that the mouse pointer is indeed visible despite being set to not be shown in the experiment settings. But a simple:

win.mouseVisible = False

In the “begin experiment” tab suffices to turn it off for me. I think the issue here is that you have so many other concurrent attempts to turn the mouse off, and inadvertently doing the opposite, that you’re overriding this one.

@TParsons is this new behaviour? I don’t have an old version to test, but it seems that we are currently missing a few parameters from some Builder component GUIs. e.g. the Mouse component doesn’t provide an option to hide the mouse pointer. There will be times when the experimenter wants to just collect button presses and not actually show the pointer, and currently this doesn’t look to be possible, without inserting a code component to make the mouse pointer invisible after it has been created. Mouse visibility probably needs to be controllable at the level of individual mouse components as well as globally.

But more generally, the “Show mouse” option in the experiment settings dialog doesn’t seem to be respected: the mouse pointer is shown whatever is set there. I can’t see what is wrong in the generated code, as the allowGUI=False parameter in the Window instantiation method is being controlled correctly. Has something changed within the Window class itself? Again, the only way to fix this seems to be to set win.mouseVisible = False after the window is created.

EDIT: looking at the source code for the Window class, I can’t actually see how the mouse visibility status is set at window creation: self.mouseVisible only seems to be explicitly set when the window closes.

Hello @Michael,

Thank you again for your response. Each of the attempts I listed were mutually exclusive so that I would not be trying more than one approach at a time. Each attempt was based on solutions that worked for others that I found on the forum or on a google group which apparently predated the forum. The odd thing is that the mouse starts out as hidden, but becomes visible once the Trial loop begins. It remains visible even if I place a second copy of the win.mouseVisible = False command in a code component within the Trial loop.

You should post a minimal working example for us to examine.

Hello @Michael

Here is a copy of the task for you to examine.

Thank you.

Anthony

Conditions.xlsx (8.6 KB) Lecture.psyexp (28.7 KB)

Hi Anthony,

I was wondering if you could solve your problem because I have the same issue. I cannot hide the cursor.
Sami

Hello Sami,

For this particular experiment set up I ended up abandoning the use of Psychopy as I was not able to resolve this issue and the issue with the task bar showing up.

Here are some code bits that might help you. The first one might be for online experiments and the second one for locally run.

You should also check out the crib sheet by wakecarter to see if there is a solution for you:

To Hide the Mouse:

document.body.style.cursor=‘none’;

win.mouseVisible = False

To Show the Mouse:

document.body.style.cursor=‘auto’

win.mouseVisible = True

2 Likes

Thank you! I had the same problem but applying this code I could solve it. :laughing:

Is this when running locally or online? Running locally there was a bug whereby the “Show mouse” option in experiment settings in Builder wasn’t compiling correctly, which is now fixed in the latest release (2022.2.1).

I’m still having the same problem running locally with the newest version - the mouse still shows up even though I have not clicked the ‘show mouse’ option and it is running fullscreen

If you click :compile_py: Compile Python, can you see a line like this?
win.mouseVisible = False
Should be on or near line 75

yes it’s there

This may have already been resolved, but in case not; I had a similar issue. I noticed the mouse disappeared at the start (presumably as a result of unchecking the “show mouse” option) and reappeared at the first routine which used a mouse component.

I added the “win.mouseVisible = False” to the begin routine tab of that first routine with the mouse component in it and it worked for the entire experiment.

i have the mouse problem too, and the line
win.mouseVisible = False
was on the “right” place. Still, the cursor appeared. BUT, after i moved this line to the place just before the rountine beginning, it worked. Problem solved, although i do not know why.

I think it is the gui command and/or any window object creation (image, text box, shape, etc) that cause the problem. Adding the

win.mouseVisible = False

command just after the creation of the last window object (text, image, shape, etc) in the .py file code seemed to solve the problem for me.

To do this using the builder:

  1. Create a routine (name does not matter - I called mine “HideMouse”)
  2. Add a “Code” block to it.
  3. In the “Code” block under the “Begin Routine” tab, add the command
    win.mouseVisible = False
  4. Click “OK”

And Bob’s your uncle.

Hopefully this helps:

1 Like