Arduino hangs at check buttons ()

Hello, i have a problem with the 3.2 tft touch display from sainsmart and the utft button library. I have an arduino mega and a selfmade shield for the display.
Problem:
When this line is executed:

int b = mybuttons.checkButtons();

no more line of code will be executed.

And I don't know why????

(deleted)

#include <UTFT.h>
#include <UTouch.h>
#include <UTFT_Buttons.h>

extern uint8_t SmallFont[];

UTouch touch(6,5,4,3,2);
UTFT myTFT(ITDB32S,38,39,40,41);  //parameters for Arduino Mega and 3,2 " Sainsmart myTFT touch display
UTFT_Buttons button(&myTFT, &touch);
  
//Parameter for Functions: 
  int display_x = 320;
  int display_y = 240;
  int stanni;
  
void setup()
{
  Serial.begin(9600);
  
  myTFT.InitLCD();
  myTFT.setFont(SmallFont);
  display_y = myTFT.getDisplayYSize();
  display_x = myTFT.getDisplayXSize();
  stanni = display_x/11;
  Serial.print(stanni);
  touch.InitTouch();
  touch.setPrecision(PREC_MEDIUM);
  button.setTextFont(SmallFont);
  

}
  int buttons[15];
  int e=-2;
  int stateloop1=1;
  int o = 0;
  int a =1;

void loop()
{

  
  if(a<2){//the buttons should be printed only once
  //clear screen, print name in the left upper corner 
  myTFT.clrScr();
  myTFT.setColor(255, 0, 0);
  //initialize buttons
  Serial.print(0);
 
  button.setButtonColors(VGA_YELLOW, VGA_RED, VGA_YELLOW, VGA_BLUE, VGA_GRAY);
  buttons[0]=button.addButton(1*stanni, 1*stanni, stanni, stanni, "0");
  buttons[1]=button.addButton(3*stanni, 1*stanni, stanni, stanni, "1");
  buttons[2]=button.addButton(5*stanni, 1*stanni, stanni, stanni, "2");
  buttons[3]=button.addButton(7*stanni, 1*stanni, stanni, stanni, "3");
  buttons[4]=button.addButton(9*stanni, 1*stanni, stanni, stanni, "4");
  buttons[5]=button.addButton(1*stanni, 3*stanni, stanni, stanni, "5");
  buttons[6]=button.addButton(3*stanni, 3*stanni, stanni, stanni, "6");
  buttons[7]=button.addButton(5*stanni, 3*stanni, stanni, stanni, "7");
  buttons[8]=button.addButton(7*stanni, 3*stanni, stanni, stanni, "8");
  buttons[9]=button.addButton(9*stanni, 3*stanni, stanni, stanni, "9");
  buttons[10]=button.addButton(9*stanni, 5*stanni, stanni, stanni, "OK");
  buttons[11]=button.addButton(7*stanni, 7*stanni, 3*stanni, stanni, "RETURN");
  buttons[12]=button.addButton(7*stanni, 5*stanni, stanni, stanni, "C");
  //draw buttons
  Serial.print(1);
  button.drawButtons();
  Serial.print(2);
  a++;
  }
  Serial.print(3);
  if(touch.dataAvailable()){//check if the screen is touched
  e = button.checkButtons();//this is where the code stops
  Serial.print(4);
  if(e==-1){
    if(o>99){
      Serial.println(-1);
      o=0;
    }else{
      o++;
    }
  }else{
    Serial.println(e);
  }
  }
}

The output in the serial monitor is 230123
the 4 isn't been printed, so this is why I know that

MrSkuff:
Problem:
When this line is executed:

int b = mybuttons.checkButtons();

no more line of code will be executed.

...

MrSkuff:

  e = button.checkButtons();//this is where the code stops}

That's why you were asked to give the full code.
Your first description of the problem is not what is in your sketch.

Your sketch seems to be calling a library to get a keypress from the shield.
That library is likely to wait for some key press, but doesn't seem to register one and so keeps waiting for it forever.
Did you incorporate the keys in your self made shield ?
And did you do that the exact same way as the example you used ?

There are 2 library called UTFT and Utouch. Utft_Buttons is for implementing simply to use Buttons and is based an the 2 other and doesn´t work without them.
The utouch library collects data from pressure point correctly==>Shield and touch works correctly.
The problem is that it hangs at the checkButtons function.
The function returns -1 when no button is pressed, so i think i doesn´t wait.

Try this, comment out touch.DataAvailable() and just put true in its place. So it would look like "if(true)"

I added this if condition to see if works then, but it doesn´t matter. it´s really the checkButtons().

You can try my library if you want, it's located in "Other Software Development" as TFT_Extension. I give plenty of example codes you can try.