# Why can't I use the back button in state 2?

**URL:** <https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360>\
**Category:** Coding Questions\
**Created:** [March 3, 2020, 7:00pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360 "2020-03-03T19:00:49Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)\
**Post date:** [March 3, 2020, 8:00pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/21 "2020-03-03T20:00:27Z")

</div>

Ich liebe dich es hat geklappt danke danke danke ❤❤

Und ich weiß jetzt wo der Fehler war

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 3, 2020, 8:05pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/22 "2020-03-03T20:05:32Z")

</div>

Verstehst du, was los war?

Die falsche Klammer hatte den gesamten Inhalt deiner Funktion draw() eingeschlossen.

Alles lief nur, wenn start == 1 galt !!!

Dies hast du nun behoben.

Übrigens, hier im Forum sagen die meisten state (Zustand) oder screen, aber nicht start zu dieser Steuer-Variable.

Hier ist meine Version. Ich habe die Datumsanzeige vereinfacht.

Chrisir

```auto

float mainx1 = 300;
float mainy1 = 400;
float mainw1 = 500;
float mainh1 = 250;
float mainx2 = 900;
float mainy2 = 400;
float mainw2 = 500;
float mainh2 = 250;
float bx = 100;
float by = 100;
float bw = 50;
float bh = 50;

int start = 0;

int sekunde;
int minute;
int stunde;
int tag;
int monat;
int yahr;

void update() {
  sekunde = second();
  minute = minute();
  stunde = hour();
  tag = day();
  monat = month();
  yahr = year();
}

void setup() {
  orientation(LANDSCAPE);
  fullScreen();
  frameRate(90);
}

void draw() {

  if (start==0) {
    background(0);
    fill(255);
    rect(mainx1, mainy1, mainw1, mainh1);
    rect(mainx2, mainy2, mainw2, mainh2);
    if (mousePressed) {
      if (mouseX>mainx1 && mouseX <mainx1+mainw1 && mouseY>mainy1 && mouseY <mainy1+mainh1) {
        start = 2;
      }
      if (mouseX>mainx2 && mouseX <mainx2+mainw2 && mouseY>mainy2 && mouseY <mainy2+mainh2) {
        start = 1;
      }
    }
  } else if (start == 2) {
    background(0);
    rect(bx, by, bw, bh);
    textSize(50);
    fill(255, 0, 0); 
    text("Fenster2", 500, 500);
    if (mousePressed) {
      if (mouseX>bx && mouseX <bx+bw && mouseY>by && mouseY <by+bh) {
        start=0;
      }
    }
  } else if (start == 1) {
    background(0);
    update();
    fill(#FFFFFF);

    textSize(200);
    text(
      nf(tag, 2) 
      + "." 
      + nf(monat, 2)
      + "."
      + nf(yahr, 2), 
      750, 450);

    textSize(75);
    text(
      nf(stunde, 2)  
      + ":" 
      + nf( minute, 2) 
      + ":" 
      + nf(sekunde, 2), 
      1157, 595);
  }
}
//

```

---

<div class="post-metadata">

**Author:** ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)\
**Post date:** [March 3, 2020, 8:40pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/23 "2020-03-03T20:40:23Z")

</div>

Aber das was ich bis jetzt kann geht für eine Woche oder?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 3, 2020, 8:43pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/24 "2020-03-03T20:43:14Z")

</div>

Großer Respekt von meiner Seite!!!

🙂

[Previous page](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360.md?page=1)
