cancel
Showing results for 
Search instead for 
Did you mean: 

How to update values of custom containers at TouchGFX?

NDura.16
Associate II

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.

1 REPLY 1
AndrewM
Associate III

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();
}