2023-08-25 01:08 AM
Hi,
For a device without touchscreen, I'm prototyping a GUI using a clickable wheel as user input. A red box is used as visual focus on widget. I tied the following code to deliver a programmatic click :
void navScreenView::selectClicked(){
Rect clickedRect = (*focused)->getFirstChild()->getAbsoluteRect();
Application* app = Application::getInstance();
int x = clickedRect.x + clickedRect.width / 2;
int y = clickedRect.y + clickedRect.height / 2;
snprintf(debugStringBuffer, sizeof(debugStringBuffer), "Click: %d, %d", x, y);
Application::invalidateDebugRegion();
ClickEvent ev = ClickEvent(ClickEvent::PRESSED,x ,y);
app->handleClickEvent(ev);
HAL::getInstance()->taskDelay(200);
ev = ClickEvent(ClickEvent::RELEASED,x ,y);
app->handleClickEvent(ev);
}
The coordinates x,y are correct, but passing the event to the application does not trigger anything.
Any advice ?
2023-09-01 04:17 AM
Hello @Fribes ,
You can simply define your widgets as 'ClickListener' through the designer and continue using your ClickEvent. You don't need to use the application in this case.
You can read more about the ClickListener here:
https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_click_listener
I hope this would help.