cancel
Showing results for 
Search instead for 
Did you mean: 

How to move the Screen from Model::tick() in a TouchGFX environment?

PKunK.1
Associate III

In the TouchGFX program, there are Model, A_Screen, and B_Screen.

It's working in A_Screen, and it's working in Model::tick()

When I have time, I want to move the screen to B_Screen.

To do this, I want to know what to do in Model::tick() to switch from A_Screen to B_Screen.

If anyone knows how, ask me for advice.

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Michael K
Senior III

Here's what I did.

  1. I was too lazy to write the screen switch code myself, so I made dummy interactions on one of my pages to switch to each of my screens in response to a hardware button press (which I don't implement). TouchGFX will automatically create methods in FrontendApplicationBase
  2. Call the following code from wherever you want to switch to your new screen, replacing <screenName> and "NoTransition" as required with whatever the automatically generated method was called.
static_cast<FrontendApplication*>(Application::getInstance())->goto<screenName>ScreenNoTransition();

View solution in original post

4 REPLIES 4
Michael K
Senior III

Here's what I did.

  1. I was too lazy to write the screen switch code myself, so I made dummy interactions on one of my pages to switch to each of my screens in response to a hardware button press (which I don't implement). TouchGFX will automatically create methods in FrontendApplicationBase
  2. Call the following code from wherever you want to switch to your new screen, replacing <screenName> and "NoTransition" as required with whatever the automatically generated method was called.
static_cast<FrontendApplication*>(Application::getInstance())->goto<screenName>ScreenNoTransition();

PKunK.1
Associate III

Thank you for teaching me a good way.

I found another way, similar to what you told me.

1. Create a button on the B_Screen (this button has an invisible property). Insert the code that switches the screen to B_Screen using the button function.

2. Copy the class of B_Screen to model.c and call the button made by B_Screen using the class copied.

I did it this way, but I checked that I was doing the action I wanted.

I will test again the way you told me.

Thank you so much from the bottom of my heart

I'll chip in just to say that I do this as well, it is more than fine but I agree that Michael's solution is cleaner :grinning_face_with_sweat: either with a dummy hardware button or a dummy widget button that i put outside of the canvas.

/Romain

You're welcome, glad it worked out!