| Reference | Downloads | Github

Hide mouse cursor in builder?

I have an experiment where subjects respond with the mouse only at the end of each trial. I have a separate routine for this response period, which includes a mouse event. The problem is, the mouse cursor is displayed throughout the entire trial, and I would like it to only display at the start of the last routine.

Is there any way to do this in Builder? Or do I have to go to the Coder view?

As a more general question, if I make a change in Coder, then that change does not carry over to the Builder, correct? So I couldn’t make behind-the-scenes changes in Coder, then continue to use Builder to finish up the task?


Insert a Code component in Builder and try something like this in the Begin routine tab:

win.mouseVisible = True

and in the End routine tab:

win.mouseVisible = False

Generally, no. A code component in Builder allows you to execute small amounts of code at relevant times, while still staying within the graphical Builder environment.

Yes, there is no way to translate the arbitrary Python code you could write and turn it back into a graphical representation. So going from Builder to Coder is very much a one-way street.

But you will likely find that using a code component within Builder allows you to achieve 99% of what you might need to do with custom code, and actually stops a lot of errors by automatically inserting the code at the right place. i.e. you get to have your cake and eat it, by using custom code but remaining within the Builder environment.


Thank you! That solution worked beautifully.

And yes, that makes perfect sense about the Coder vs. Builder. I have been using the code components, but ran into some issues with not knowing where the code is executed relative to the drawing of the stimuli, etc. I guess the solution is to occasionally peek at the Coder view and figure out through trial-and-error.

I could program the whole thing in Coder, but I like how Builder constrains things for me. That’s what I don’t like about Psychtoolbox-- it’s infinitely flexible, which means everyone is free to write terrible code to accomplish simple things. :slight_smile:

Just one quick follow-up question:

If I didn’t ask in the forum, where would be the best place to find the solution to this problem? The API section under documentation? I tried browsing through but never stumbled across the win.mouseVisible option.

Yes, in similar situations, I tend to put in a comment string like # XXX in my code component and then do a quick search for XXX in the Coder view to quickly locate it in the compiled script.

Yes, start with the API. No one will ever complain if you do your homework there first and then follow-up with unresolved questions here on the forum :wink:
In this case, check out the page for the Window class:

I have a similar problem but when I tried this recommendation, it did not work in my case.
I have the rating component in the same routine and that the rating is done as the last activity in the routine. I still see the mouse cursor right from the beginning of the experiment till the end. Please help me to make the mouse cursor visible only during the rating period. I have included the screenshot.

I finally got it by taking out the rating component and making it a routine on its own. I also inserted this code instead [your_mouse = event.Mouse(visible = False)] and it worked. Thanks

For me, the mouse cursor is hidden at the start of the experiment as long as ‘Show mouse’ is unchecked in Experiment Settings > Screen, but the mouse cursor becomes visible when the program executes a movie component and remains visible for the remainder of the experiment.

Inserting a code component in the same routine as the movie component and using ‘win.mouseVisible = False’ (or ‘your_mouse = event.Mouse(visible = False)’, as suggested above) fails to hide the mouse cursor, regardless of whether this line of code is added to ‘Begin Experiment’, ‘Begin Routine’, or ‘Each Frame’.

Has anybody else seen this behaviour when using a movie component?

Hi @Michael,

I am trying to do the same on Pavlovia i.e. I want to hide the cursor at the beginning of a routine but display it again as the routine ends. But the code does not work.

Also, is it required to insert a ‘mouse’ component in the routine for it to work?