Question
Click on a widget without touchscreen
- August 25, 2023
- 1 reply
- 1064 views
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 ?
