cancel
Showing results for 
Search instead for 
Did you mean: 

Changing screen programatically

Priyank
Associate III

Hi I was wondering what the best method is to change screens programatically. I saw

application().gotoXScreenNoTransition()

and also

static_cast<FrontendApplication*>(Application::getInstance())->gotoXScreenNoTransition(); 

Is there any difference in efficiency for the program?

1 REPLY 1
GaetanGodart
ST Employee

Hello @Priyank ,

 

The 2 methods are similar in efficiency (technically slightly more efficient to go for application().gotoXScreenNoTransition() but this is very negligeable).

The difference is that the method application().gotoXScreenNoTransition() is simpler, more readable, and type-safe if application() returns the correct type directly.
On the other hand, static_cast<FrontendApplication*>(Application::getInstance())->gotoXScreenNoTransition() allows casting to a more specific type, which is useful if Application::getInstance() returns a base class pointer and you need to access derived class methods.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)