Nested Menu Programming: Switch Case Evaluation Problem

Hi fellow Arduinhombres,

I'm trying to create a nested menu that will eventually allow a user to edit multiple fields within the menu. Before I actually get to the editing part and passing those values into specific elements in arrays I need help with my nested switch case statements. The problem I am encountering is the input, a button press, keeps on getting evaluated in the initial Switch Case statement and it ignores that fact that it is in a totally different function or Switch Case statement.

Here is the basic layout right now: A single button (pin13) and a 16x2 lcd display(Pins 2-5, 11, 12):

Here is my code:

#include <LiquidCrystal.h>

const int buttonPin = 13;

int a=0;
int b=0;

//Valve Attributes
int userInvalve []={0,1,2,3,4};
int userInduration []={5,10,15,20,25};
int userInsetpoint []={100,200,300,400,500};
float calcIncurrent []={0.00, 0.00, 0.00, 0.00, 0.00};

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void editMenu();
void editValve(int);


void setup() {
   
  pinMode(buttonPin, INPUT);
  digitalWrite(buttonPin, HIGH );
  lcd.begin(16, 2);  
  
}

void loop() {

    switch (checkButton()){
      case 1:
        
        if(a>4) a=0;
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Sta# ");
        lcd.setCursor(4, 0); 
        lcd.print(userInvalve[a]);
        lcd.setCursor(7,0);
        lcd.print("T' ");
        lcd.setCursor(11,0);
        lcd.print(userInduration[a]);
        lcd.setCursor(0,1);
        lcd.print("Set");
        lcd.setCursor(4,1);
        lcd.print(userInsetpoint[a]);
        lcd.setCursor(7,1);
        lcd.print("Acc");
        lcd.setCursor(11,1);
        lcd.print(calcIncurrent[a]);
        a++;        
        break;
    
      case 2:
        editMenu();        
        break;
    }  
   
}

int checkButton() {//returns a value of 1 or 2 depending on if button is a single of double click    
}

void editMenu(){
  int a=0;
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Edit Station");
  lcd.setCursor(0,1);
  lcd.print("Attributes...");
  delay(2000);
  lcd.clear();
  
  lcd.setCursor(0,0);
  lcd.print("Station #");
  lcd.setCursor(8,0);
  lcd.print(a);
  
  switch(checkButton()){
    case 1:
       a++
       if(a>4) a=0;
       lcd.setCursor(0,0);
       lcd.print("Station #");
       lcd.setCursor(8,0);
       lcd.print(a);     
      break;
    case 2:
      editValve(a);
      break;
  }
} 

void editValve(int){
}

Now when I execute the program the first Switch Case statement works just fine. I can manually scroll with a single click through the stations and see the status and current settings of each valve. I double click and I know that the editMenu function has been called because I can see the initial message on the screen appearing for two seconds. It works fine up until it is time to evaluate the Switch Case statement in the editMenu() subroutine. When I single click the button it is my expectation that it will advance to the next station. Or if I double click I would expect the program to advance to the editValve() subroutine.

What happens instead is the evaluation happens once again at the initial Switch Case statement. So say I've moved into the editMenu() subroutine and I single click the button the display reverts to the station status screen or if I double click the button it runs the editMenu() subroutine again. So my question is how can I move deeper into the Switch Case statements without it reevaluating the button press to the initial statement everytime.

*for brevity I have removed the code from the checkButton subroutine. I can include it if the problem isn't immediately obvious.

Thank you for your help.

You may be have switch bounce problems.

I've ruled that out for the most part. When I use the station query(single button press) I don't see any instability. I can perform single clicks on it all day and it never misinterprets it as a double click and advances to the editMenu subroutine. The button press functionality was copied from Jeff's Arduino Blog: Click for A, Press and Hold for B.

Could it be that I'm missing a break somewhere?