Hello! I am currently trying to create my own version of paint. I want my menus to be popup windows. I have two separate windows created for the two different menus. The problem I currently have is that 1) I don’t know how to get them to minimize without physically clicking the minimize button and 2) when I click ‘p’ or ‘m’ (the keys for each of the windows) it creates a whole new window so basically you end up with an infinite amount of windows. Hopefully that is not too confusing. I am open to any help, my code is below! Thanks!
class homeWindow extends PApplet {
homeWindow() {
super();
PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
}
void settings() {
size(1000, 300);
}
void setup() {
background(150);
}
void draw() {
if (focused != true) {
redraw();
}
}
void mousePressed() {
//launch("%windir%/explorer.exe shell:::{3080F90D-D7AD-11D9-BD98-0000947B0257}"); minimize
}
void keyPressed() {
if (key == 'm' || key == 'M') {
win = new menuWindow();
}
}
}
class menuWindow extends PApplet {
menuWindow() {
super();
PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
}
void settings() {
size(300, 800);
}
void setup() {
background(150);
}
void draw() {
if (focused != true) {
redraw();
}
}
void mousePressed() {
}
void keyPressed() {
if (key == 'h' || key == 'H') {
win2 = new homeWindow();
}
}
}
menuWindow win;
homeWindow win2;
public void settings() {
fullScreen();
}
void setup() {
win = new menuWindow(); //Opens main menu on start
background(255);//Set background color
}
void draw() {
//Left Brush
if (mousePressed && mouseButton == LEFT) {
strokeWeight(8); //Sets brush thickness
stroke(255, 0, 0); //Sets brush color
line(mouseX, mouseY, pmouseX, pmouseY);
}
//Right Brush
if (mousePressed && mouseButton == RIGHT) { // Rectangular Eraser
strokeWeight(1); //Resets to default weight
fill(255); //Sets fill to background color
stroke(255); //Sets stroke to background color
ellipse(mouseX, mouseY, 55, 55);
}
}
void keyPressed() {
//Opens Main Menu
if (key == 'm' || key == 'M') {
win = new menuWindow();
}
if (key == 'h' || key == 'H') {
win2 = new homeWindow();
}
}