cancel
Showing results for 
Search instead for 
Did you mean: 

Callback from a common custom container to the current view

Professional
Senior

Hello

I have a custom container common to several screen (with OK button in it).

How can i call a callback of the current screen when a button is pressed in the container ?

I do call the callback of the custom containe, but don't know how to propagate it to the current view.

(for example when OK button is pressed i want to execute the action in each view containing this custom container)

I there an example of this ?

thanks

regards

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

Here it is. A project that defines a screen with two custom containers (Both CustomContainer1). CustomContainer1 has a background and a ClickListener Box. When the Box is pressed, the CustomContainer catches this in an internal handler and then calls a Callback (set by the view) to communicate it's identity back. Based on this identity (The first or the second custom container) it will show/hide the custom containers.

I've written some comments in the code - Let me know if you need more information.

View solution in original post

19 REPLIES 19
Martin KJELDSEN
Chief III

Hi @Professional​,

Just to let you know i've seen your question. I'm traveling right now, but i I will create an example that shows you how to do this.

Best regards,

Martin

Thanks a lot for your support !!!

Professional
Senior

Hello,

do you know when you will be able to create this example ?

thanks

Hello

do you know when the example will be available ?

Thanks

Martin KJELDSEN
Chief III

Here it is. A project that defines a screen with two custom containers (Both CustomContainer1). CustomContainer1 has a background and a ClickListener Box. When the Box is pressed, the CustomContainer catches this in an internal handler and then calls a Callback (set by the view) to communicate it's identity back. Based on this identity (The first or the second custom container) it will show/hide the custom containers.

I've written some comments in the code - Let me know if you need more information.

Professional
Senior

Hello thank you for your example;it doesn't compile in visual studio but I will try to make it work in my project !

best regards

Martin KJELDSEN
Chief III

I used Visual Studio 2017, so it does work, but you may need to retarget to whatever version you're using.

Martin KJELDSEN
Chief III

You can also simply "Run Simulator" from within the designer to compile using gcc. Both should work.

VKyri
Associate

Hey. I'm trying, as an example, to use CallBack with the CustomContainer. But I do not use Box, I use FlexButton with include TextArea.

From the Widget Box, the declaration looks like:

touchgfx::ClickListener< touchgfx::Box > box2;

So that the function call looks like:

box2.setClickAction(boxClickedCallback);

When used with FlexButton, the declaration looks like:

touchgfx::ClickListener< touchgfx::TextButtonStyle< touchgfx::BoxWithBorderButtonStyle< touchgfx::ClickButtonTrigger > > > btn0;

And now when:

btn0.setClickAction(boxClickedCallback);

I am getting an error when compiling:

no matching function for call to 'touchgfx :: ClickListener <touchgfx :: TextButtonStyle <touchgfx :: BoxWithBorderButtonStyle <touchgfx :: ClickButtonTrigger>>> :: setClickAction (touchgfx :: Callback <NumPad, const touchgfx :: ClickButtonTrigger &, const touchgfx :: ClickEvent &> &) '