Skip to main content
NDura.16
Associate
November 22, 2021
Question

How to update values of custom containers at TouchGFX?

  • November 22, 2021
  • 1 reply
  • 1047 views

Hi,

I created custom container for spesific purpose and I want to see USB connection status there. Therefore, I have to update the value of status continuously. Custom containers does not have presenter.cpp file and I do not refresh the value simultaneously.

Thanks.

This topic has been closed for replies.

1 reply

AndrewM
Associate III
January 4, 2022

If I understand you correctly, you'd like to be able to access the presenter pointer from within a custom container that belongs to the relevant view class?

I use this technique a lot. Basically in your custom container you just need a data member of type 'pointer to Presenter' and a function to set the data member eg

// in eg UsbContainer.hpp 
class UsbContainer : public UsbContainerBase
{
public:
 ...
 void setPresenter(MyPresenter* presenter)
 {
 presenter_ = presenter;
 }
 void display()
 {
 ...
 int state = presenter_->getUsbState(); 
 show(state);
 ...
 }
 ...
protected:
 ...
 MyPresenter* presenter_{nullptr};
 ...
};
 
// in eg MyView.cpp
void MyView::setupScreen()
{
 MyViewBase::setupScreen();
 usbContainer.setPresenter(presenter);
 usbContainer.display();
}