‎2019-12-02 04:12 AM
I'd like to only update variables, which are shown on the current screen. How do I get the current screen in a switch case structure, in the model::tick() function. I tried to alter the tick function to get the currentScreen parameter from the FrontendApplication.hpp as a variable, but this did not work
Solved! Go to Solution.
‎2019-12-02 06:11 AM
I'd simply store the active screen in the model when you activate a screens presenter.
class MyView;
class MyPresenter : public Presenter, public ModelListener
{
public:
MyPresenter(MyView& v);
/**
* The activate function is called automatically when this screen is "switched in"
* (ie. made active). Initialization logic can be placed here.
*/
virtual void activate()
{
model->setActiveScreen(MYSCREEN);
}
...
‎2019-12-02 06:11 AM
I'd simply store the active screen in the model when you activate a screens presenter.
class MyView;
class MyPresenter : public Presenter, public ModelListener
{
public:
MyPresenter(MyView& v);
/**
* The activate function is called automatically when this screen is "switched in"
* (ie. made active). Initialization logic can be placed here.
*/
virtual void activate()
{
model->setActiveScreen(MYSCREEN);
}
...
‎2019-12-02 07:15 AM
Ah thank you, that is actually an easy still elegant solution.=)
‎2019-12-04 12:47 AM
I think so too. You could do some type-checking magic, but this is a lot simpler and more readable.
/Martin