cancel
Showing results for 
Search instead for 
Did you mean: 

Using Triggers and Actions

Priyank
Associate III

Hi I am having some trouble regarding using actions and triggers. I've been following the Tutorial 5 from the support website to use them, but I could use some suggestions regarding my situation.

I have a container which is a button which appears 4 times on 1 screen.

I want the container, when clicked to emit a value to the screen. 

When I try to emit a value of my choosing . What are my options as to what I can emit? I don't mean data types, but I mean data. Earlier when I tried to emit a variable from the model.cpp, it said it cannot emit that because the variable is not apart of the containers generated base code. Is this true, that only data found in the base file of the container can be emitted?

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @Priyank ,

 

Yes, this is normal.

If you want to understand more how it works, create a new action, trigger and interaction and go look at base file for the custom container. You will see that the above mentioned element have been created and the function has a parameter of the specific type mentioned.

Because using an action, trigger and function basically just calls a function, you need to know the type in advance to generate the correct function in the base file.

So basically, the error you can read is correct : you need to declare the variable you want to use.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

View solution in original post

3 REPLIES 3
GaetanGodart
ST Employee

Hello @Priyank ,

 

It is possible to send a data (a variable) from a custom container to the screen that it is in.

Since your custom container is meant to act as a button, maybe this tuto would help you.

Otherwise, you can have a look at the color picker example, see attached files.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

Hello @GaetanGodart I guess my question is that, I am able to send data from the container to the screen using Triggers and interactions on the container. The problem seems to be that I can only send data scoped within the containers base file. Here is an example where I successfully emitted data out, and it worked because the button Buffer is apart of the containers base file. When I try to send data which exists outside of the generated base file, it does not work. When I build it, I get an error in the base.cpp saying the variable was not declared in this scope

 

 

Screenshot 2024-11-21 111721.png

 

 

Hello @Priyank ,

 

Yes, this is normal.

If you want to understand more how it works, create a new action, trigger and interaction and go look at base file for the custom container. You will see that the above mentioned element have been created and the function has a parameter of the specific type mentioned.

Because using an action, trigger and function basically just calls a function, you need to know the type in advance to generate the correct function in the base file.

So basically, the error you can read is correct : you need to declare the variable you want to use.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)