cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if a container button is pressed from screenView.cpp

Jj.21
Associate II

How to know if a button of the custom container located in (...\TouchGFX\generated\gui_generated\src\containers\TestBottonsBase.cpp) is pressed when we are inside of  (...\TouchGFX\gui\src\screen_screen\screenView.cpp).

I don't know how to define a flag inside of TestBottonsBase.cpp and check it inside of screenView.cpp.

Is there any other solution rather than defining a flag? 

 

TestBottonsBase.cpp :

void TestButtonsBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)

{

if (&src == &testButton1)

{

[define a flag  here]

}

}

 

screenView.cpp :

void screenView::handleTickEvent()

{

[check that flag here]

}

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @Jj.21,

When you create your custom container and place a button inside it, you can easily use the available Interactions to assign your desired functionality. Therefore, you don't need to check whether the clicked button was part of your TestButton

Also, it is good to point out that the files generated by TouchGFX which are placed at gui_generated should not be modified by the users because they will be regenerated and replaced when TouchGFX regenerates code. 

Bottom line, you can set an interaction for your button (like the picture below):

Defining an InteractionDefining an Interaction

And modify the user container code (MyCustomContainer.cpp and MyCustomContainer.hpp in this case) as you need it.

In case you want to communicate data (like a value) between the container and the screen, then I suggest following Tutorial 5 to learn about the process.

I hope this helps you!
Don't hesitate to ask more questions if you have any!

Mohammad MORADI
ST Software Developer | TouchGFX

View solution in original post

2 REPLIES 2

Hello @Jj.21,

When you create your custom container and place a button inside it, you can easily use the available Interactions to assign your desired functionality. Therefore, you don't need to check whether the clicked button was part of your TestButton

Also, it is good to point out that the files generated by TouchGFX which are placed at gui_generated should not be modified by the users because they will be regenerated and replaced when TouchGFX regenerates code. 

Bottom line, you can set an interaction for your button (like the picture below):

Defining an InteractionDefining an Interaction

And modify the user container code (MyCustomContainer.cpp and MyCustomContainer.hpp in this case) as you need it.

In case you want to communicate data (like a value) between the container and the screen, then I suggest following Tutorial 5 to learn about the process.

I hope this helps you!
Don't hesitate to ask more questions if you have any!

Mohammad MORADI
ST Software Developer | TouchGFX

Thank you. Your advice was very helpful.