cancel
Showing results for 
Search instead for 
Did you mean: 

Why callback handler executed twice on single touch?

NK
Associate II

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();

}

}

1 ACCEPTED SOLUTION

Accepted Solutions
Sebastiaan
Senior

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

View solution in original post

6 REPLIES 6
Sebastiaan
Senior

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

Thank you.

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

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

NK
Associate II

Okay. Actually I am the beginner so I am bit confused. Thank you!

And do you have sufficient info now? Did you manage to understand it and get it working?

NK
Associate II

Yes Sebstiaan. My application is working correctly. Thank you for the support!