Why is this ui function crashing my sketch when i build

i have a function called uiUpdate that runs fine in the preview but freezes the app when i build it. i know this function is responsible, but i don’t know why. here is the entire ui class, i have to comment out every uiUpdate call in the main class in order to build without freezing. what’s going on here


boolean hUP;
int iUP;
boolean hDOWN;
int iDOWN;
boolean hRIGHT;
int iRIGHT;
boolean hLEFT;
int iLEFT;
boolean hR;
int iR;
boolean hE;
int iE;
boolean hSPACE;
int iMOUSE;
int iRMOUSE;
int iMMOUSE;
boolean hENTER;
int iENTER;
boolean hSHIFT;
int iSHIFT;
boolean hTAB;
int iTAB;
float mouseScroll;
float mouseSV = 0;
float msLAST = 0;
void uiUpdate(){
  if(mousePressed&&mouseButton==LEFT){
    if(iMOUSE == 0){
      iMOUSE = 1;
    } else {
      iMOUSE = 2;
    }
  } else {
    iMOUSE = 0;
  }
  if(mousePressed&&mouseButton==RIGHT){
    if(iRMOUSE == 0){
      iRMOUSE = 1;
    } else {
      iRMOUSE = 2;
    }
  } else {
    iRMOUSE = 0;
  }
  if(mousePressed&&mouseButton==CENTER){
    if(iMMOUSE == 0){
      iMMOUSE = 1;
    } else {
      iMMOUSE = 2;
    }
  } else {
    iMMOUSE = 0;
  }
  if(hENTER){
    if(iENTER == 0){
      iENTER = 1;
    } else {
      iENTER = 2;
    }
  } else {
    iENTER = 0;
  }
  if(hSHIFT){
    if(iSHIFT == 0){
      iSHIFT = 1;
    } else {
      iSHIFT = 2;
    }
  } else {
    iSHIFT = 0;
  }
  if(hTAB){
    if(iTAB == 0){
      iTAB = 1;
    } else {
      iTAB = 2;
    }
  } else {
    iTAB = 0;
  }
  if(hR){
    if(iR == 0){
      iR = 1;
    } else {
      iR = 2;
    }
  } else {
    iR = 0;
  }
  if(hE){
    if(iE == 0){
      iE = 1;
    } else {
      iE = 2;
    }
  } else {
    iE = 0;
  }
  
  if(hUP){
    if(iUP == 0){
      iUP = 1;
    } else {
      iUP = 2;
    }
  } else {
    iUP = 0;
  }
  if(hDOWN){
    if(iDOWN == 0){
      iDOWN = 1;
    } else {
      iDOWN = 2;
    }
  } else {
    iDOWN = 0;
  }
  if(hRIGHT){
    if(iRIGHT == 0){
      iRIGHT = 1;
    } else {
      iRIGHT = 2;
    }
  } else {
    iRIGHT = 0;
  }
  if(hLEFT){
    if(iLEFT == 0){
      iLEFT = 1;
    } else {
      iLEFT = 2;
    }
  } else {
    iLEFT = 0;
  }

  mouseScroll=round(mouseScroll*0.5);
}

void keyPressed(){
  if(keyCode == 38 || keyCode == 87){
      hUP = true;
  }
  if(keyCode == 39 || keyCode == 68){
      hRIGHT = true;
  }
  if(keyCode == 37 || keyCode == 65){
      hLEFT = true;
  }
  if(keyCode == 40 || keyCode == 83){
      hDOWN = true;
  }
  if(keyCode == 82){
    hR = true;
  }
  if(keyCode == 69){
    hE = true;
  }
  if(keyCode == 32){
    hSPACE = true;
  }
  if(keyCode == 10){
    hENTER = true;
  }
  if(keyCode == 16){
    hSHIFT = true;
  }
  if(keyCode == 9){
    hTAB = true;
  }
  //println(keyCode);
}
void keyReleased(){
  if(keyCode == 38 || keyCode == 87){
      hUP = false;
  }
  if(keyCode == 39 || keyCode == 68){
      hRIGHT = false;
  }
  if(keyCode == 37 || keyCode == 65){
      hLEFT = false;
  }
  if(keyCode == 40 || keyCode == 83){
    hDOWN = false;
  }
  if(keyCode == 82){
    hR = false;
  }
  if(keyCode == 69){
    hE = false;
  }
  if(keyCode == 32){
    hSPACE = false;
  }
  if(keyCode == 10){
    hENTER = false;
  }
  if(keyCode == 16){
    hSHIFT = false;
  }
  if(keyCode == 9){
    hTAB = false;
  }
}

void mouseWheel(MouseEvent event) {
  mouseScroll = event.getCount();
}

What error do you get?

i don’t get an error. it runs fine in preview, but crashes in build

Can we get some details about your platform?

i am building for macos but i have the same problem when i build for windows

i recognize this is a frustrating lack of information, that’s why it’s so confusing for me too haha

Can you post the entire sketch if you have a github that would be great. Ill see what i can do. Are you building an executable or making a project folder?

i am building an executable, hold on

Thanks ill take a look when i get a min

can you include the svg files please.

oh right got it, should be up now

application built first time

you might want to try a fresh install. Delete the temp folder, make sure your java is up to date, download and reinstall processing and see what happens.

All export modes work for me apart from mac as I dont have the hardware.

that’s weird. i’ll try the build on pc again, thanks

1 Like