Skip to main content
Associate III
November 17, 2025
Solved

the button be pressed, not release, keep pressed state!

  • November 17, 2025
  • 2 replies
  • 250 views

one box in the screen, then create a button on box, meant to change the color of box, when button pressed; simulator -> OK; but download to board, running denormal , when button pressed, finger off, button not release, still pressed state, why? (use STM32F429I_DISCO BOARD CUBEIDE)

Best answer by redstone8415

just make a test! 

2 replies

ST Employee
November 18, 2025

Hello @redstone8415.

Can you share your project? I just did a quick test, and I do not see any issues.

Best regards,
Johan

Associate III
November 19, 2025

the problem is solved, 

box1.setColor(touchgfx::Color::getColorFromRGB(rand()&0xff, rand()&0xff, rand()&0xff));  here to blocking!

to comment out, button is normal!

correction method:

void Screen1View::buttonClicked()
{
 static uint32_t counter = 0;
 counter++;
 
 // Direct color composition (avoids function call)
 uint32_t r = (counter * 13) & 0xFF;
 uint32_t g = (counter * 37) & 0xFF;
 uint32_t b = (counter * 71) & 0xFF;
 
 touchgfx::colortype newColor = (r << 16) | (g << 8) | b;
 box1.setColor(newColor);
 box1.invalidate();
}

 

ST Employee
November 19, 2025

Okay, great to hear!

Is there a reason why you do not use a flex button? Using a flex button allows embedding the box and click functionality within a single widget.

Best regards,
Johan

redstone8415AuthorBest answer
Associate III
November 23, 2025

just make a test!