Hiding mouse for some componenets within the same routine

Hello all, I checked the similar topics but it seems that the problem is not solved yet. I have different components within the same routine and I want to hide the mouse when some of the components are presented but make the mouse visible in the rest. Is that possible?
right now I am using locally but I will transfer the study to pavlovia.

Thanks

I use this code to show/hide the mouse for different routines:

Show mouse (Phyton / Javascript)

win.mouseVisible = False / document.body.style.cursor = "none";

Hide mouse (Phyton / Javascript)

win.mouseVisible = True / document.body.style.cursor='auto';

You can add some additional condition inside each routine to show the mouse at specific times (e.g. from 3 to 5 seconds after the routine starts)

2 Likes

Hey, thanks for the answer but this didnt work when I pasted to either of the locations (begin exp begin routine etc.).
Also could you please show how to restrict the time? Like I want it to be invisible from 0 to 1.5 secs

Let’s say that you want the mouse to be invisible from 0 to 1.5 secs

Phyton Code

Begin Routine tab

myClock = core.Clock() 
win.mouseVisible = False

Each Frame tab

if myClock.getTime() >= 1.5:
    win.mouseVisible = True

Javascript Code

Begin Routine tab

myClock = new util.Clock();
document.body.style.cursor = "none";

Each Frame tab

if ((myClock.getTime() >= 1.5)) {
    document.body.style.cursor='auto';
}
1 Like

Personally I prefer to use flags to stop a command being repeated every frame

Begin Routine

myClock = core.Clock() 
win.mouseVisible = False
showMouse = False

Each Frame

if showMouse == False and myClock.getTime() >= 1.5:
    win.mouseVisible = True
    showMouse = True
2 Likes

Perfectly worked! Thanks a lot

Hey there,

Sorry for writing under solved question but the code gave an error in the online version. This is the error:

I am coding and psychopy novice I would be really appreciated if you tell me how to change a JS code step by step.

Thank you,
Bests

myClock = new util.Clock();

should I set the coding as Both and change the JS code?

or
In a video I saw that they do the following:
Before experiment
in JS part say

var core.Clock() = new util.Clock(); 

I’ve always used a Both component in Begin Experiment without the word var

I set it Both inserted this to the begin Exp JS part. However, I am receiving the same error in Pavlovia

Have you use Ctrl-Shift-R or an incognito tab or a different browser or a different device to view the latest version?

No, I am trying it from google chrome on laptop, no incognition tab

[quote=“wakecarter, post:12, topic:26400”]
use Ctrl-Shift-R
[/quote] in Chrome to run the latest version. You can’t get a core.Clock constructor error with your latest code if it doesn’t mention core.Clock

tried Ctrl-Shift-R, still receiving the error.

Am I doing something wrong while changing the code?

set both > begin exp > only in JS part write myClock = new util.Clock(); > ok

in begin routine I should keep

myClock = core.Clock() 
win.mouseVisible = False
showMouse = False

right? or should i remove it?

Please could you show a screenshot of your code component.

Did you add the JS version of creating a clock to the JS side instead of replacing the Python version?


It would be easier to view if you removed the empty lines.

Yes you do appear to have added instead of replaced.

should I change
new core.Clock() to new util.new util.Clock(); on the JS side here?

I would say yes but you appear to have new twice and util twice in your proposed edit. Please look at my initial post or my crib sheet for the syntax.