Cannot change focus on menu boxes

Hi
I have the following code. This is partial code being used on a controller on a 3.2" tft screen using an Arduino mega.
There are 2 arrows, up and down for changing the value in the box at these coords. If I touch the "amount" at another location I want to use the same up and down arrow but alter that amount instead.
It won't change focus from the first amount I touched until I exit the screen and go back in again.
What have I missed adding please?

if (Enter_new_dose == true){
          if((y >= 217) && (y <= 252)){                             // two y-coordinates (142/169)
          if ((x >= 66) && (x <= 98)){                             // Down Button by 1's
            waitForIt(66, 217, 98, 251);                 

            if (change_dose == 1){
              if (Pump1dose > 0){
                 Pump1dose -= 1;           
                    x=0;
                    y=0; 
                      
                  if (Pump1dose <= 9){
                  myGLCD.setFont(arial_bold);
                  myGLCD.setBackColor(255,255,255);                  
                  myGLCD.print(" ", 63, 39);                              //Clear Number for less digits
                }
               }
              } 
              
             if(change_dose == 2){
               if (Pump2dose > 0){
                  Pump2dose -= 1;
                     x=0;
                     y=0;
              
                  if (Pump2dose <= 9){
                  myGLCD.setFont(arial_bold);
                  myGLCD.setBackColor(255,255,255);                  
                  myGLCD.print(" ", 186, 39);                              //Clear Number for less digits
                }
               }
              }
                              
              if (change_dose == 3){
                if (Pump3dose > 0){  
                   Pump3dose -= 1;
                     x=0;
                     y=0;
               
                  if (Pump3dose <= 9){
                  myGLCD.setFont(arial_bold);
                  myGLCD.setBackColor(255,255,255);
                  myGLCD.print(" ", 63, 139);                              //Clear Number for less digits
                }
               }
              }
              
              if (change_dose == 4){
                if (ATO > 0){  
                   ATO -= 1;
                     x=0;
                     y=0; 
                             
                  if (ATO <= 9){
                  myGLCD.setFont(arial_bold);
                  myGLCD.setBackColor(255,255,255);
                  myGLCD.print(" ", 186, 139);                              //Clear Number for less digits
                }
               }
              }
             Print_DoseAmount();
            }              
          
          
          
            if ((x >= 102) && (x <= 134)){
               waitForIt (102, 217, 134, 251);
                
                if (change_dose == 1){
                if (Pump1dose >= 0){
                    Pump1dose += 1;           
                    x=0;
                    y=0;            
               }
              }          
                if(change_dose == 2){
                if (Pump2dose >= 0){
                    Pump2dose += 1;
                    x=0;
                    y=0;                    
               }
              }              
                if (change_dose == 3){
                if (Pump3dose >= 0){  
                    Pump3dose += 1;
                    x=0;
                    y=0;                   
               }
              }
                if (change_dose == 4){
                if (ATO >= 0){  
                    ATO += 1;
                    x=0;
                    y=0;                    
               }
              }                  
             }        
            Print_DoseAmount();
           }
          }

You need to post the full code, you can make it an attachment under Additional Options. And please format it, if not done already.

Okay
I formatted it and added the whole code.

AquaPornEdit.ino (92.5 KB)

I am regretting asking to see the full code and the name of your sketch has me scratching my head.

Aside from that, do you know if you're going into the Print_DoseAmount() function, once you change your amount?

Lol. That ugly eh?Its for a reef controller. The name refers to an inside joke.

Is that not what we are doing here?

            if ((x >= 102) && (x <= 134)){
               waitForIt (102, 217, 134, 251);
                
                if (change_dose == 1){
                if (Pump1dose >= 0){
                    Pump1dose += 1;           
                    x=0;
                    y=0;            
               }
              }          
                if(change_dose == 2){
                if (Pump2dose >= 0){
                    Pump2dose += 1;
                    x=0;
                    y=0;                    
               }
              }              
                if (change_dose == 3){
                if (Pump3dose >= 0){  
                    Pump3dose += 1;
                    x=0;
                    y=0;                   
               }
              }
                if (change_dose == 4){
                if (ATO >= 0){  
                    ATO += 1;
                    x=0;
                    y=0;                    
               }
              }                  
             }        
            Print_DoseAmount();
           }
          }

with the Print_DoseAmount() at the end of the function?

I see that but, if you can only see the change when you switch screens, then that leads me to think something is not allowing you to actually update the screen. Try to debug your code by showing a number in the corner of the screen and see if the number increases as you go through the functions and if statements. This will let you know if your actually inside your print function.

I'll give you a link to my TFT extension library that works with your UTFU and UTouch libraries if your interested. It has all different buttons that may be of some use.

Okay will give it a try. Thanks
I should add we can see the change straight away however cannot switch to changing another number without changing screens first

Post a picture If you can of your screens. What it's showing and what it should be showing. Make sure your pictures are at a decent size before you post them, nothing too big or small.

The first image shows the screen with nothing selected
The second shows the adjustment arrows that are common to all 4 input areas and that I have selected the input area in the top right and used the arrows to change the dose amount. That input area now has a red box around it
The 3rd image shows that I have touched the lower right input area but the focus remains on the upper right one, the red box remains there and is the only one I can change.
What am I missing adding in the code to make the red highlight to the new input area to make more changes?

Change_dose never gets set back to zero until you change the screen.
So for this section to work, change_dose must be set back to zero.

if (dosingato_screen == true){

if((y >= 32) && (y <=60 )){ // two y-coordinates
if ((x >= 56) && (x <= 120)){ //Touch Pump1 dose button
if (change_dose == 0){ //Selection to change dose Pump1
waitForIt(56 , 32, 120, 60);
change_dose = 1;
Enter_new_dose = true;
doseState = false;
}
y = 0;
x = 0;
}
if ((x >= 177) && (x <= 239)){ //Touch Pump2 dose Button
if (change_dose == 0){ //Selection to change dose Pump2
waitForIt(177, 32, 239, 60);
change_dose = 2;
Enter_new_dose = true;
doseState = false;
}
y = 0;
x = 0;
}
}

if((y >= 133) && (y <=160 )){
if ((x >= 56) && (x <= 120)){ //Touch Pump3 dose Button
if (change_dose == 0 ){ //Selection to change dose Pump3
waitForIt(56, 133, 120, 160);
change_dose = 3;
Enter_new_dose = true;
doseState = false;
}
y = 0;
x = 0;

}
if ((x >= 177) && (x <= 239)){ //Touch ATO dose button
if (change_dose == 0){ //Selection to change ATO dose
waitForIt(177, 133, 239, 160);
change_dose = 4;
Enter_new_dose = true;
doseState = false;
}
y = 0;
x = 0;
}
}
}

To fix this you need to keep track of the pump your on and check to see if another pump is selected. If it is, set change_dose back to zero. The better way would be to get rid of "if(change_dose == 0)" and just check the button coordinates to see if you are within the button area. If you are, change the pump.

Okay. Will give that a try.
Thank you for your help

No1Daemon:
Okay
I formatted it and added the whole code.

I suspect the following doesn't do what you want:

void Print_DoseAmount(){
                                                       
    if (dosingato_screen == true);

In the other functions that if statement has an open bracket if I'm not mistaken. I don't think that's your problem but it wouldn't hurt to fix it.

Regards,

Brad
KF7FER

Thanks. Will fix it.