Why callback handler executed twice on single touch?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-31 11:26 PM
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();
}
}
Solved! Go to Solution.
- Labels:
-
TouchGFX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-31 11:44 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-31 11:44 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-31 11:52 PM
Thank you.
Could you please tell me where can I call ClickEvent and set parameters?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-01 12:12 AM
Well it's not you who has to set it, but you have to check it on entering your callback function "boxClickHandler" .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-01 12:15 AM
Okay. Actually I am the beginner so I am bit confused. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-01 12:41 AM
And do you have sufficient info now? Did you manage to understand it and get it working?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-01 1:44 AM
Yes Sebstiaan. My application is working correctly. Thank you for the support!
