2022-11-02 06:00 AM
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.
Solved! Go to Solution.
2022-11-02 08:35 AM
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 ;)
2022-11-02 06:56 AM
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
2022-11-02 07:13 AM
Thank you. I'll develop that.
2022-11-02 08:15 AM
I pass the values from the view to model, than back to the view... it keeps doing the turning to zero when changing screen
2022-11-02 08:35 AM
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 ;)
2022-11-02 08:59 AM
That's what i was thinking.... thanks a lot it worked like a charm.