Skip to main content
Riccardo Franceschetto
Associate III
November 2, 2022
Solved

Text on wildcard sets to initial value after changing screeen

  • November 2, 2022
  • 5 replies
  • 1472 views

Hello,

I'm implementing an application with touchgfx, i use wildcards with buffer, and two buttons that increse or decrease the value in the wildcard.

When i go back to previous screen, and re enter the screen with wildcards, those resets to initial value "0" that i set in touchgfx designer, then when i press the buttons to increase or decrease the value, this updates correctly to the value where it last was set, but only after changing it.

How do i keep this values shown after i change and re enter the screen, without them changing to zero?

Thanks a lot.

This topic has been closed for replies.
Best answer by MM..1

On enter any screen is all objects reset to designer setup and your user part function is called before show screen (render)

Your code must restore from stored values viewed objects.

void Screen1View::setupScreen()
{
 Screen1ViewBase::setupScreen();
 
... your init code

 and ofcourse your code after base call, not before ;)

5 replies

Yoann KLEIN
ST Employee
November 2, 2022

Hello,

The best way to insure that the values will remain the same between the different screens is to store them in the Model, which is a common resource for every screen. You could update your values in the Model after clicking on the button in the UI, and on the same hand send the value to the UI from the Model when needed, through the Presenter.

I provided an example of that practice on a post, some months ago. The application was dealing with a Clock, but the principle remains the same, so you should succeed pretty easily.

To fully understand how it works, I encourage you to read some documentation articles, especially the one dealing with the Model-View-Presenter pattern.

Let me know if you have other questions.

/Yoann

Yoann KLEINST Software Developer | TouchGFX
Riccardo Franceschetto
Associate III
November 2, 2022

Thank you. I'll develop that.