cancel
Showing results for 
Search instead for 
Did you mean: 

How to switch screen from model.cpp?

manto.1
Senior

The question was already asked but still not answered.

I was trying to use:

application().goto() functions but unsccesful.

https://community.st.com/s/question/0D53W00000xqBlLSAU/how-can-i-switch-screen-from-model-class-in-response-to-external-event-backend-event

6 REPLIES 6
Romain DIELEMAN
ST Employee

Hi,

It is not possible at the moment (actually I think a user on the forum shared his workaround but cant seem to find it). What are you trying to do exactly ? Same thing as the post you shared ? In his case what i would recommend is just to implement dummy transitions in one of the screens to generate all the application.goto() functions needed and add a function receiving the hardware input (see backend communication article) which then calls the relevent screen transition. You'll have to implement that same function in all screens of your project (we are aware this is annoying and are working on it :grinning_face_with_sweat:).

/Romain

ssipa.1
Associate II

Hi @Romain DIELEMAN , Do you have an updated answer for this as of March 2025? Do I still need to override a function in every screen to handle an event that triggers a screen switch?

Romain DIELEMAN
ST Employee

I am not part of the TouchGFX team anymore but I think it was judged not to proceed with this, due to the MVP code structure.

I'll let a current member of the team correct me if this has changed.

karsparskambala
Associate III

Hi @Romain DIELEMAN , thank you for the prompt response. I understand, that makes sense.

GaetanGodart
ST Employee

Hello @karsparskambala ,

 

If you want to change from one screen to another based on some external event that will call a function, you need to have an interaction in your current screen to go to the desired screen.
You can do that by adding an interaction where the trigger is "hardware button clicked" and you select a hardware button that you never use, or you can create a dummy action at screen level and use that action as trigger, then for the rest of the interaction, just select "change screen" then your destination screen, etc.
It means that you have to create an interaction for every possibilities that you want.
That interaction will create a function that you can directly call.

 

I hope this answers your question!
If it doesn't, can you please give me more context?

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)