cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX and ClickListener Debounce/Delay

Kneepatch
Senior

I am having trouble with the ClickListener. I am trying to debounce the click event somehow. My first instinct is to delay and then check to see if the click is still present, but I am not sure it will work with this function because it seems that the click is an event that is triggered. For example, here is one of my click hander calls:

void MainView::circleClickHandler(const touchgfx::Circle& c, const ClickEvent& evt)
{

Any suggestions on what the proper way to debounce a ClickListener object is? The buttons that are built-in widgets seem to do this with no additional code. Thanks in advance!

P.S. - programming with the STM32F469I-DISCO board. 

1 ACCEPTED SOLUTION

Accepted Solutions
Kneepatch
Senior

OK, so I figured out how to make this work:

void MainView::circleClickHandler(const touchgfx::Circle& c, const ClickEvent& evt)
{
 
	if(evt.getType() == touchgfx::ClickEvent::PRESSED){
 
	    if (&c == &headCircle)
	    {..}
}

Thanks for the tip to use the click event type!

View solution in original post

6 REPLIES 6
Osman SOYKURT
ST Employee

Hello Kneepatch,

I'm not sure to have understood what do you mean by "debounce" the click event. Can you clarify this?

Do you want to get the click status?

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX

Yes, I think that click status might do the trick! Whenever I pressed a button, it would seem to "unclick" itself, and I think that's because it was triggering whenever I RELEASED. I'll try it and come back if that doesn't work, thanks!

Having trouble getting the compiler to recognize my syntax here, trying to get the ClickEventType from the ClickEvent parameter:

void MainView::circleClickHandler(const touchgfx::Circle& c, const ClickEvent& evt)
{
 
	if(evt.getEventType() == ClickEventType::PRESSED){

I get the error:

MainView.cpp:35:27: error: 'ClickEventType' has not been declared

Kneepatch
Senior

OK, so I figured out how to make this work:

void MainView::circleClickHandler(const touchgfx::Circle& c, const ClickEvent& evt)
{
 
	if(evt.getType() == touchgfx::ClickEvent::PRESSED){
 
	    if (&c == &headCircle)
	    {..}
}

Thanks for the tip to use the click event type!

You're welcome!

Osman SOYKURT
ST Software Developer | TouchGFX

Great to hear you succeed ;)

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX