Skip to main content
Kneepatch
Senior
Solved

TouchGFX and ClickListener Debounce/Delay

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. 

This topic has been closed for replies.
Kneepatch
KneepatchBest answer
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!

-Kneepatch

6 replies

Osman SOYKURT
ST Technical Moderator

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

ST Software Developer | TouchGFX
Kneepatch
KneepatchAuthor
Senior

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!

-Kneepatch
Osman SOYKURT
ST Technical Moderator

You're welcome!

ST Software Developer | TouchGFX
Kneepatch
KneepatchAuthorBest answer
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!

-Kneepatch
Osman SOYKURT
ST Technical Moderator

Great to hear you succeed ;)

/Osman

ST Software Developer | TouchGFX