Skip to main content
Kneepatch
Senior
December 14, 2022
Solved

TouchGFX and ClickListener Debounce/Delay

  • December 14, 2022
  • 6 replies
  • 2749 views

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.
Best answer by Kneepatch

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!

6 replies

Osman SOYKURT
ST Technical Moderator
December 14, 2022

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
December 14, 2022

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
December 16, 2022

You're welcome!

ST Software Developer | TouchGFX
Kneepatch
KneepatchAuthorBest answer
Senior
December 15, 2022

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
December 16, 2022

Great to hear you succeed ;)

/Osman

ST Software Developer | TouchGFX