cancel
Showing results for 
Search instead for 
Did you mean: 

Communication from screen to backend

KNara.2
Associate III

Hi,

I'm trying to send an event when a button is clicked.

I have added an interaction in Touchgfx designer to call a virtual function when the button is clicked.

In Screen1view.cpp I'm overwriting the virtual function

void SendDataOnButtonClicked()
{
presenter->SetMode();
}

in presenter.cpp

void Screen1Presenter::SetMode()
{
model->SendEvent();
}

In Model.cpp

void Model::SendEvent()
{
Send data to backend.
}
Is this the correct way of sending data to backend when button is clicked ?
 
Right now I'm stuck at view.cpp.
I dont know how to call presenter  from view.
Codes that I tried.
Method 1:
Screen1ViewBase::presenter->SetMode();
Method 2:
Method 2:
presenter->SetMode();
 
Both these codes are throwing compiler errors.
Can somebody please help and let me know the right way of accessing the function in presenter?
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
JTP1
Lead

Hello. Method 2 is correct. There must some simple problem at hpp file maybe ... This 'void SendDataOnButtonClicked()' must be of course 'void Screen1View::SendDataOnButtonClicked()'.

What is the exact error ?

Here you can get simple example of MVP communication in both directions:

https://community.st.com/t5/stm32-mcu-products/toggle-button-off-after-a-specific-interval/m-p/569065#M217071

View solution in original post

2 REPLIES 2
JTP1
Lead

Hello. Method 2 is correct. There must some simple problem at hpp file maybe ... This 'void SendDataOnButtonClicked()' must be of course 'void Screen1View::SendDataOnButtonClicked()'.

What is the exact error ?

Here you can get simple example of MVP communication in both directions:

https://community.st.com/t5/stm32-mcu-products/toggle-button-off-after-a-specific-interval/m-p/569065#M217071

KNara.2
Associate III

Thank you so much @JTP1 .

Your solution helped.