Why does the cursor reappear when I enter fullScreen?

Hello,

I was hoping someone might know why this is happening and how to stop it from happening. I have the cursor hidden, but once I click to go fullscreen the cursor reappears. Please take a look at the code, any suggestions welcome! Thank you!

var lastKeyPressed;
var Red;
var Green;
var Blue;
var Yellow;

var r;
var R
var g;
var G;
var b;
var B;



function setup() {
  noCursor();

  Red = color(R, G, B);
  Green = color(163, 255, 163);
  Blue = color(163, 212, 255);
  Yellow = color(249, 242, 47);


  color1 = color(204, 172, 0);
  color2 = color(249, 211, 32);
  color3 = color(243, 243, 21);

  color4 = color(222, 165, 110);
  color5 = color(252, 86, 5);
  color6 = color(108, 255, 0);

  color7 = color(217, 189, 189);
  color8 = color(165, 0, 101);
  color9 = color(255, 0, 128);

  color10 = color(188, 168, 192);
  color11 = color(118, 10, 228);
  color12 = color(255, 0, 0);

  color13 = color(149, 196, 200);
  color14 = color(51, 99, 130);
  color15 = color(125, 249, 255);

  color16 = color(178, 191, 158);
  color17 = color(0, 188, 168);
  color18 = color(204, 51, 255);

  color19 = color(67, 13, 1);
  color20 = color(218, 250, 0);
  color21 = color(75, 6, 255);

  color22 = color(56, 73, 255);
  color23 = color(17, 248, 255);
  color24 = color(221, 255, 6);


  // ellipseSizeX = 200;
  // ellipseSizeY = 200;
  r = 255;
  R = r;
  g = 0;
  G = g;
  b = 60;
  B = b;

  createCanvas(displayWidth, displayHeight);
  frameRate(15);
  background(255, 0, 0);

}
var ellipseSizeX = 200;
var  ellipseSizeY = 200;
function keyPressed() {
if (keyCode == UP_ARROW) {
  ellipseSizeX += 10;
  ellipseSizeY += 10;
  noCursor();
}

if (keyCode == DOWN_ARROW) {
  ellipseSizeX -= 10;
  ellipseSizeY -= 10;

}
}
//
// function keyPressed() {
//   if (keyCode == UP) {
//     ellipseSizeX += 10;
//     ellipseSizeY += 10;
//   }
//
//   if (keyCode == DOWN) {
//     ellipseSizeX -= 10;
//     ellipseSizeY -= 10;
//   }


function draw() {
    noCursor();
  // if (showInstruction){
//  fill(0);
//  textAlign(CENTER, CENTER);
//  textSize(30);
//  textStyle(BOLD);
//  textLeading(35);
//  textFont("Helvetica");
//
//  text("Color Fader." + "\n" +
//    "Press keyboard letters to fade to different color moods." + "\n",
//    "Press down arrow and up arrow to change the size of the circles."+ "\n" , width * 0.5, height * 0.5);
//
//  }
  noCursor();
  if (r != R) {
    if (r >= R) {
      R++;
    } else if (r < R) {
      R--;
    }
  }

  if (g != G) {
    if (g >= G) {
      G++;
    } else if (g < G) {
      G--;
    }
  }

  if (b != B) {
    if (b >= B) {
      B++;
    } else if (b < B) {
      B--;
    }
  }

  if (r == R && g == G && b == B) {
    r = R;
    g = G;
    b = B;
  }

  // *********NOTE:  the code below changes the effect to have ellipses slowly fill the screen with the new color.
  // Comment out the following when using it:
  // background(R, G, B);
  for (var i = 0; i < 300; i++) {
    var randoms = random(255);
    var testW = int(random(width));
    var testY = int(random(height));

    fill(R, G, B);
    noStroke();
    ellipse(mouseX, mouseY, ellipseSizeX, ellipseSizeY);

  }


  // background(R, G, B);
  lastKeyPressed = key;

  if (key === 'a') {
    r = red(color1);
    g = green(color1);
    b = blue(color1);
  } else if (key === 's') {
    r = red(color2);
    g = green(color2);
    b = blue(color2);
  } else if (key === 'd') {
    r = red(color3);
    g = green(color3);
    b = blue(color3);
  } else if (key === 'f') {
    r = red(color4);
    g = green(color4);
    b = blue(color4);
  } else if (key === 'g') {
    r = red(Green);
    g = green(Green);
    b = blue(Green);
  } else if (key === 'h') {
    r = red(color5);
    g = green(color5);
    b = blue(color5);
  } else if (key === 'j') {
    r = red(color6);
    g = green(color6);
    b = blue(color6);
  } else if (key === 'k') {
    r = red(color7);
    g = green(color7);
    b = blue(color7);
  } else if (key === 'l') {
    r = red(color8);
    g = green(color8);
    b = blue(color8);
  } else if (key === 'z') {
    r = red(color9);
    g = green(color9);
    b = blue(color9);
  } else if (key === 'x') {
    r = red(color10);
    g = green(color10);
    b = blue(color10);
  } else if (key === 'c') {
    r = red(color11);
    g = green(color11);
    b = blue(color11);
  } else if (key === 'v') {
    r = red(color12);
    g = green(color12);
    b = blue(color12);
  } else if (key === 'b') {
    r = red(Blue);
    g = green(Blue);
    b = blue(Blue);
  } else if (key === 'n') {
    r = red(color13);
    g = green(color13);
    b = blue(color13);
  } else if (key === 'm') {
    r = red(color14);
    g = green(color14);
    b = blue(color14);
  } else if (key === 'q') {
    r = red(color15);
    g = green(color15);
    b = blue(color15);
  } else if (key === 'w') {
    r = red(color16);
    g = green(color16);
    b = blue(color16);
  } else if (key === 'e') {
    r = red(color17);
    g = green(color17);
    b = blue(color17);
  } else if (key === 'r') {
    r = red(color19);
    g = green(color19);
    b = blue(color19);
  } else if (key === 't') {
    r = red(color18);
    g = green(color18);
    b = blue(color18);
  } else if (key === 'y') {
    r = red(Yellow);
    g = green(Yellow);
    b = blue(Yellow);
  } else if (key === 'u') {
    r = red(color20);
    g = green(color20);
    b = blue(color20);
  } else if (key === 'i') {
    r = red(color21);
    g = green(color21);
    b = blue(color21);
  } else if (key === 'o') {
    r = red(color22);
    g = green(color22);
    b = blue(color22);
  } else if (key === 'p') {
    r = red(color23);
    g = green(color23);
    b = blue(color23);
  } else if (key === ',') {
    r = red(color24);
    g = green(color24);
    b = blue(color24);
  }
  noCursor();
}
// function ellipseSize(){


function mousePressed() {
    noCursor();
  onPressed = true;
  if (mouseX > 0 && mouseX < 1200 && mouseY > 0 && mouseY < 1200) {
    var fs = fullscreen();
    fullscreen(!fs);
  noCursor();
  }
  // if (mouseReleased){
  //     showInstruction = false;}
  // if (showInstruction) {
  //   background(255);
  //   showInstruction = false;
  // }
}
function mouseReleased() {
    noCursor();
  onPressed = false;

}

Answers

  • How to post in the processing forum.

    Best is to hit ctrl-t in processing first before copy paste into the forum (https://forum.processing.org).

    You can edit your post (click the small gear and the 'Edit').

    How to format Code:

    empty line before and after the code section
    
    select (highlight) entire code with the mouse
    
    hit ctrl-o OR click the small C in the command bar
    
  • edited January 2018

    just repeat noCursor(); in function windowResized()?

    https://p5js.org/reference/#/p5/windowResized

  • OK, I added this code to the bottom, but the cursor still reappeared.

    function windowResized() {
    resizeCanvas(windowWidth, windowHeight);
        noCursor();
    }
    
Sign In or Register to comment.