2021-05-26 11:20 AM
I have a screen and two different backgrounds. I have a Toggle button. How to change the background with this button?
Andrzej
Solved! Go to Solution.
2021-05-27 03:06 AM
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)
/Romain
2021-05-27 01:03 AM
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
2021-05-27 01:49 AM
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.
Can I program it to display in the same field after switching background?
Andrzej
2021-05-27 03:06 AM
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)
/Romain
2021-05-27 03:59 AM
Thank you. I will try.
Andrzej
2021-05-28 11:09 AM
2021-05-29 02:47 AM
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