Bringing experiment to full screen after some loops

Hi,

I’m coding an experiment with PsychoJS and I had a problem with bringing experiment to full screen.

The experiment starts with

psychoJS.openWindow({
    fullscr: false,
    color: new util.Color('black'),
    units: 'norm'
});

I need to bring the window to full screen after a loop. So in the scheduler function of the full screen loop, I added

psychoJS.window.adjustScreenSize();

According to the source code this should be the function. But it doesn’t seem to work. There is also no log related to window size such as ‘Unable to go fullscreen’ or 'Resizing Window: ’ in console.

I have also tried having a dedicated scheduler just for this function. But it’s still the same.

Please let me know where I should put this function and if I missed something here.

Thanks!
Yu Li

It looks like this function should work since it is used by the core.gui API when a window is opened with “fullscr: true”:

// switch to full screen if requested:
self._psychoJS.window.adjustScreenSize();

Has anyone have experience calling this function in their experiment?

After digging around a bit more I found out that the “adjustScreenSize()” checks window.fullscr before bringing the window to full screen. Should have check this function first.

For anyone who wants to enable/disable fullscreen after initialization, window.fullscr needs to be set along with adjustScreenSize() or closeFullScreen().

Please could you give the exact JS code you used for JavaScript novices? I feel like I wouldn’t know what to type in the JS window without further research.

This code snippet worked for me:

psychoJS.window.fullscr = true;
psychoJS.window.adjustScreenSize();

Hi,

This may seem like a basic question, but where did you input that code snippet to bring the experiment to full screen? At the beginning of the routine you want to be full screen, or outside it in some scheduler function?

Try a Begin Routine tab in the routine you want to be full screen

Thanks for the prompt response! I tried that and got an error that says: “NameError: name ‘true’ is not defined.” It’s weird because I wrote the word true in lower case and without quotes. I just invited you to the repo on GitLab, if you are free to take a look! Or if you have other suggestions on how to combat this, I will try them out.

Did you write that code in a JS only code component? true (lower case) should be defined in JS unless you are defining it twice.

Yes, I’ve uploaded to the JS only component.

I just ran it with no error messages (I got three recordings). Use Ctrl-Shift-R to ensure you are running the latest code.

Thank you very much for checking! I just ran it on a different Internet browser (I was trying to run it on Safari, but switched to Google Chrome and Mozilla Firefox) and it works now.