Why callback handler executed twice on single touch?
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();
}
}
