Skip to main content
NK_it
Associate III
September 1, 2021
Solved

Why callback handler executed twice on single touch?

  • September 1, 2021
  • 6 replies
  • 1149 views

I am trying to change the box colour from Red to Green then Green to blue on every single click but on single click box color directly changes from RED to BLUE..for very short duration it appears GREEN. 

FYI

.hpp

  void boxClickHandler(const Box& b,const ClickEvent& e);

  enum colorChange{RED,GREEN,BLUE};

  colorChange cc=RED;

protected:

  Callback<Screen2View, const Box&, const ClickEvent&>boxClickedCallback;

.cpp

Screen2View::Screen2View():boxClickedCallback(this, &Screen2View::boxClickHandler)

{

}

void Screen2View::setupScreen()

{

Screen2ViewBase::setupScreen();

//Add the callback to the box

box1.setClickAction(boxClickedCallback);

}

 void Screen2View::boxClickHandler(const Box& bx, const ClickEvent& evt)

{

if((cc==RED))

{

//Change the box color to GREEN.

cc=GREEN;

box1.setColor(touchgfx::Color::getColorFrom24BitRGB(0,255,0));

box1.invalidate();

}

else

{

box1.setColor(touchgfx::Color::getColorFrom24BitRGB(0,0,255));

box1.invalidate();

}

}

This topic has been closed for replies.
Best answer by Sebastiaan

Is the event raised only on a click, or also on a release?

You can try by 'clicking' for 2 seconds before releasing.

see https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_click_event

6 replies

Sebastiaan
SebastiaanBest answer
Associate II
September 1, 2021

Is the event raised only on a click, or also on a release?

You can try by 'clicking' for 2 seconds before releasing.

see https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_click_event

NK_it
NK_itAuthor
Associate III
September 1, 2021

Thank you.

Could you please tell me where can I call ClickEvent and set parameters?

Sebastiaan
Associate II
September 1, 2021

Well it's not you who has to set it, but you have to check it on entering your callback function "boxClickHandler" .