cancel
Showing results for 
Search instead for 
Did you mean: 

Touch GFX, STM32F746G-DISCO, STM32CubeIDE

ADębs.1
Senior

I have a screen and two different backgrounds. I have a Toggle button. How to change the background with this button?

Andrzej

1 ACCEPTED SOLUTION

Accepted Solutions

You can use the same trick of turning the buttons or counter invisible when you switch backgrounds. What you have to be careful about is in which order you have put the widgets in: as long as you put the text "above" in the tree then your text will be displayed above the background (dont forget to use the invalidate() function)

0693W00000APzIzQAL.png 

/Romain

View solution in original post

6 REPLIES 6
Romain DIELEMAN
ST Employee

Hi,

What widget are you using for the background ? Are they images or just plain boxes ?

The easiest solution would be to add the two backgrounds on top of each other and just set one of them to invisible (go to the widget settings tab and uncheck the "Visible" box for one of the two background). Go to the "Interactions" tab in TouchGFX Designer and create an interaction with as trigger "Button is clicked" and as action either "Execute C++ code" or "call new virtual function", depending on what you prefer, and set the logic through code with something like this for example.

if( background_1.isVisible() )  // check if the first background is visible. If yes, make it invisible
{
      background_1.setVisible(false);
      background_2.setVisible(true);     // turn the other background visible
}
else   //do the opposite
{
      background_1.setVisible(true);
      background_2.setVisible(false);    
}
 
      background_1.invalidate();
      background_2.invaldiate();

Have a look at the UI templates available in TouchGFX Designer and the documentation to understand how to work with the different widgets and the TouchGFX functionalities.

/Romain

ADębs.1
Senior

Thanks for the hint. I will check. I am sending two images that I want to replace.

On one background, I want to set the time with the buttons. I want to display the counting on the second background.

0693W00000APxDsQAL.png0693W00000APxCVQA1.pngCan I program it to display in the same field after switching background?

Andrzej

You can use the same trick of turning the buttons or counter invisible when you switch backgrounds. What you have to be careful about is in which order you have put the widgets in: as long as you put the text "above" in the tree then your text will be displayed above the background (dont forget to use the invalidate() function)

0693W00000APzIzQAL.png 

/Romain

ADębs.1
Senior

Thank you. I will try.

Andrzej

Hi

I did as you advised. What I did works. I have to add a little more. However,

I have a problem. It does not send the variables sec and min to main.c. Instead, it sends the start.

Why?

greetings

Andrzej

Hi Romain!

I added a screen to the last program.

When switching to the second screen, min and sec rewrite to main.c. How to get rewritten to main.c after changing the value with buttons, eg ButtonAddSec?

greetings

Andrzej