cancel
Showing results for 
Search instead for 
Did you mean: 

Change widget of the current active screen when an event is received

KNara.2
Associate III

Hi,

Lets say I have 10 screens and I want to display an image when an event is received on the current active screen.

This is my current implementation.

In model.h

private:

bool displayimage;

public:

void setdisplayimage(bool value)

{

displayimage = value;

}

bool getdisplayimage()

{

return displayimage;

}

In model.cpp

void Model::tick() const

{

on receiving event 

setdisplayimage(true);

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

}

screen1 presenter class

bool Screen1Presenter::GetStatus() const

{
bool getValue = model->getdisplayimage();
return getValue;
}

screen1 view class

void Screen1View::setupScreen()
{
Screen1Base::setupScreen();

displaywidget();
}

void Screen1View::handleTickEvent()
{
displaywidget();
}
void Screen1View::displaywidget()
{
bool status = Screen1ViewBase::presenter->GetStatus();
if(status == 0x00)
{
widget.setVisible(true);
widget.invalidate();

}

else

{

widget.setVisible(false);
widget.invalidate();

}

}

My question is - Does it cause a overhead in handletickevent() to regularly check whether the boolean variable is set?

Is there a better solution than this?

1 REPLY 1
Yoann KLEIN
ST Employee

Hello @KNara.2,

I'm gonna close this topic, since you created a similar one for the same question, here.

Yoann KLEIN
ST Software Developer | TouchGFX