Toggling fullscreen

Hello, i couldn’t find anything useful on the topic about toggling fullscreen (like F11 in browsers for example). Also how do i run a windowed sketch at the size of the screen? Because if I try this:

void setup(){
  size(displayWidth,displayHeight);
}

im getting an error.

Thanks in advance!
-Ripolas

Hi @ripolas ,

Guess you are searching for that …

Cheers
— mnse

no, sorry if i was not clear in the beggining. I meant that i wanna have like a button or somethign to trigger fullscreen then get back to windowed

Would something like this work? It uses windowResize(). Hit space bar to get full screen; hit some other key to reset.

final int _wndW = 400;
final int _wndH = 400;

void setup() {
  size(_wndW, _wndH);
  surface.setResizable(true);
  background(209);
}

void draw() {
}

void keyPressed() {
  if (key == 32) { // space bar
    windowResize(displayWidth, displayHeight);
  } else {
    windowResize(_wndW, _wndH);
  }
}

1 Like

I tried replacing this with fullScreen() which doesn’t work.

fullScreen() does MORE than windowResize(displayWidth, displayHeight); since the position gets also changed.

Can we change the position to 0,0 ?

You might try the windowMove method.

1 Like

Can we change the position to 0,0 ?
setLocation() might work:https://processing.org/reference/setLocation_.html

1 Like

Hi