# Why is this ui function crashing my sketch when i build

**URL:** <https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871>\
**Category:** Coding Questions\
**Created:** [March 26, 2021, 1:29pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871 "2021-03-26T13:29:49Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 26, 2021, 1:29pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871/1 "2021-03-26T13:29:49Z")

</div>

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

```auto

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();
}

```

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 26, 2021, 2:50pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871/2 "2021-03-26T14:50:20Z")

</div>

What error do you get?

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 26, 2021, 3:01pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871/3 "2021-03-26T15:01:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 26, 2021, 3:03pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871/4 "2021-03-26T15:03:25Z")

</div>

Can we get some details about your platform?

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 26, 2021, 3:32pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871/5 "2021-03-26T15:32:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 26, 2021, 3:32pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871/6 "2021-03-26T15:32:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 26, 2021, 3:43pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871/7 "2021-03-26T15:43:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 26, 2021, 4:01pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871/8 "2021-03-26T16:01:14Z")

</div>

i am building an executable, hold on

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 26, 2021, 4:08pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871/9 "2021-03-26T16:08:39Z")

</div>

> **[CANSLP/topdown\_base](https://github.com/canslp/topdown_base)**
>
> Contribute to CANSLP/topdown\_base development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 26, 2021, 5:20pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871/10 "2021-03-26T17:20:04Z")

</div>

Thanks ill take a look when i get a min

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 27, 2021, 1:40pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871/11 "2021-03-27T13:40:37Z")

</div>

can you include the svg files please.

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 27, 2021, 2:04pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871/12 "2021-03-27T14:04:52Z")

</div>

oh right got it, should be up now

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [March 27, 2021, 2:12pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871/13 "2021-03-27T14:12:01Z")

</div>

application built first time

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/c6bb21c6c236ae6001d584c9a860a92c2e4fadbd.png)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/fc58ed4d82673709f47cde05674b0eb4dbaf413d.png)

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.

---

<div class="post-metadata">

**Author:** ![canslp](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@canslp](https://discourse.processing.org/u/canslp)\
**Post date:** [March 27, 2021, 2:30pm UTC](https://discourse.processing.org/t/why-is-this-ui-function-crashing-my-sketch-when-i-build/28871/14 "2021-03-27T14:30:25Z")

</div>

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