2024-12-16 09:58 AM - last edited on 2024-12-16 10:55 AM by Andrew Neil
Hi, I was wondering the safety regarding using a presenter within a container? I need the container, on click, to send information to the model. I cannot do this from the view, because this is a onclick function.
Is it safe for me to define/set the presenter of the screen in the container then use it in the container?
2024-12-16 10:48 AM
Is this a TouchGFX question?
2024-12-16 10:50 AM
I put it under IDE since that is where the code for this would go, however yes, I am using TouchGFX for development as well.
2024-12-16 10:57 AM
As the question is all about TouchGFX stuff (presenter, container, model, view, onclick function), I'll move it.
2024-12-17 05:52 AM
Hello @Priyank ,
I am not familiar with "onclick function".
In my knowledge, the simplest way is to use the view. Find attached an example of this.
I have tried to bypass the use of the view but without much success.
Why do you want to use the presenter? What is preventing you from; using the view?
Regards,
2024-12-17 08:48 AM
Hi @GaetanGodart ,
The reason I want to use the presenter is because the container holds data that the model needs. The container is a button, and it has a virtual function which I called onClick, when clicked. When clicked it sets a variable I created on the container to true. I need now to send this value to the model so the model knows it was clicked. So essentially, clicking the container will set the containers variable to true and simultaneously send this to the model. I already have a callback attached to this because the screen changes using other information from the container.
Another example I would need this is for the keyboard container. Although the keyboard is able to change the value of a text area on screen, the model, which holds the data/data structure, needs to be sent the data as soon as the keyboards submit button is clicked. Context: I have a keyboard container on each screen where the keyboard is used.
2024-12-17 08:56 AM
Ok but then you do not have to bypass the use of the view.
So the example I shared would work for you.
Clicking on the button inside the custom container triggers an interaction that emits a trigger.
This trigger is caught on the view level in an interaction that call a function.
This function calls a function in the presenter that call a function in the model and the information is passed.
Now you can do the same but also send a parameter in the function.
Tell me if you can achieve what you want.
Regards,