cancel
Showing results for 
Search instead for 
Did you mean: 

Click on a widget without touchscreen

Fribes
Associate

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 ?

1 REPLY 1

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.

ClickListener Option in the DesignerClickListener Option in the Designer

 

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.

Mohammad MORADI
ST Software Developer | TouchGFX