cancel
Showing results for 
Search instead for 
Did you mean: 

Another function is called when a button is clicked in TouchGFX.

mSH.1
Associate III

  1. The operation of the touch button was confirmed through the example of the existing TouchGFX.

0693W00000Nr65tQAB.png

I reviewed the Button example in TouchGFX Designer.

0693W00000Nr65ZQAR.png

As in the captured image above, I figured out the structure of the function that is called when the touch button is pressed using a break in MainViewBasee.cpp

0693W00000Nr66SQAR.png

If you break the break in "void MainViewBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)"

and look at each step, you can see that it is normally called with a normally defined function.

0693W00000Nr68JQAR.png

However, the problem is that other functions are called in the project you created yourself.

It should be "SC5_1_decreaseValue" or "SC5_1_increaseValue",

but "void Screen5_1View::tearDownScreen()" is called.

0693W00000Nr68dQAB.pngIf you apply the brake, press "botton_up" and confirm with a single step,

0693W00000Nr69MQAR.png 

After entering the condition in button_up in the if statement, it is executed as the button_down part in the next step.

and

in the next step

"void Screen5_1View::tearDownScreen()"

will run as

There doesn't seem to be much difference compared to the example source that works normally, but what the hell is the problem?

4 REPLIES 4
Yoann KLEIN
ST Employee

Hello @mSH.1​ ,

To be honest, I don't understand your question.

Can you please provide more details on how should your project work, what is happening and what's wrong ?

Could you also edit or reformulate some parts of your post, because it's quite confusing and hard to understand.

Thanks,

/Yoann

Yoann KLEIN
ST Software Developer | TouchGFX

Sorry for the inaccurate explanation

Let's tidy up

If you look at the captured figure at the bottom, it is a callback function for when the button is pressed, and there is a virtual function to be executed in that function.

-> increaseValue();

-> decreaseValue();

However, the function that is actually executed is teardownscreen().

even if you brake

Teardownscreen() is called even when running in single step.

The difference from the basic example is that the teardownscreen() function seems to have only a difference in definition.

There is no teardownscreen() function in the basic example.

mSH.1
Associate III

I found a warin by myself

The problem was that I did not put anything in the virtual function in view.cpp in the gui folder.

Hello,

Like the documentation says, tearDownScreen() is called before a screen stops being displayed, and can be used to clean up some resources before exiting the screen.

If you only want to increase/decrease values on a counter, without ever switching screens, it is not normal that this function is called.

I didn't succeed on reproducing your error, but I created a project, based on the Button example from TouchGFX Designer, and which also allows me to switch to an other screen using buttons. If you put a breakpoint in the method tearDownScreen() from Screen1View.cpp, you will see that this function is triggered only when you press the right-bottom corner button on the second screen, right before the application switches back to the main screen.

I will join my project to this post, so you could compare the differences between your project and mine.

Let me know how it's going,

/Yoann

Yoann KLEIN
ST Software Developer | TouchGFX