cancel
Showing results for 
Search instead for 
Did you mean: 

Setting button pressed and released events

kb24
Senior

I am using normal buttons and I set an interaction like this0693W000007EMHUQA4.jpgI saw this function will be called when button is released in this link -> https://community.st.com/s/question/0D50X0000BKAnAV/is-there-a-way-to-have-button-trigger-on-the-press-of-the-button-and-not-the-release

and I want to have event when it is pressed. I went AbstractButton.cpp for this and I did some changes but I couldn't see any effect. 0693W000007EMQ2QAO.jpgI added printf but couldn't see anything on the screen, I commented out functions but it is still firing callback.

Here is the callback0693W000007EMWPQA4.jpgIn this callback I tried to use getPressedState() function to see if released or pressed but TouchGFX IDE always deletes what I write.

Can you help me to solve this problem?

4 REPLIES 4
kb24
Senior

I modified ClickButtonTrigger.hpp to see something but TouchGFX doesn't compile that file. I also tried to have compiling errors with wrong parenthesis in AbstractButton.cpp but I couldn't get from there too. I could see those errors when I modified AbstractButton.hpp so only this file compiled for AbstractButton.

Lagodolio
Senior

I'm not a TouchGFX expert so I'm not sure I can help you...

I noticed you have a buttonCallbackHandler(..), so I think you are using a "normal" button. ClickButtonTrigger seems (in my opinion) to be used by flexButtonCallbackHandler, so you have to use a flexbutton.

Surely, my solution isn't the best one, as you have to re-modify the ScreenViewBase.cpp every time you modify the TouchGFX layout, but this is the life!

kb24
Senior

Yes my buttons are normal buttons. I could get what I want but I still have questions. TouchGFX creates this in AbstractButton.hpp0693W000007EdSZQA0.jpg 

and below function in AbstractButton.cpp but it doesn't compile that file.0693W000007EdSeQAK.jpg 

And I was knowing its compiling AbstractButton.hpp so I put that function in AbstractButton.hpp also added some code to fire callback when button pressed.0693W000007EdUQQA0.jpg0693W000007EdUVQA0.jpgIt is firing my callback when button is both pressed and released. Now I have some flags to store button statuses. And I can change data to run and stop motors. TouchGFX doesn't delete this codes so I dont have to modify it every time.0693W000007EdX5QAK.jpg

As I said before I changed location of handleClickEvent AbstractButton.cpp to AbstractButton.hpp. And I saw its working in this location. I commented out this functions0693W000007EdY8QAK.jpgand as expected I saw none of the buttons were working. How buttons were working before location change if it needs this function? And isn't there better way to get pressed event?