Skip to main content
Yunus ARI
Senior
January 21, 2020
Solved

How can I handle drag event in custom container?

  • January 21, 2020
  • 3 replies
  • 1595 views

Hi everyone,

I am trying design a custom container that needs to "handleDragEvent" function. But this function cannot be overridden in a container, as far as I see. This function can be usable when you work in a screen. But when you work in a custom container it's not working.

I tried create a function for drag event in custom container and call this function in a screen's "handleDragEvent" function. Like that;

void testScreenView::handleDragEvent(const touchgfx::DragEvent& evt)
{
 
 if(customContainer.isVisible()) { 
 customContainer.customDragEvent(evt);
 }
 
}

When I do that custom container drag event works very well. But this time screen's scrollable containers not working properly.

What should I do? Anybody have any idea? Thanks in advance.

This topic has been closed for replies.
Best answer by Martin KJELDSEN

What you're doing is effectively "stealing" the event from the rest of the components in the view, by only telling your custom container about it.

In the start of your handler, try this to propagate the event:

 View::handleClickEvent(evt);

/Martin

3 replies

Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
January 21, 2020

What you're doing is effectively "stealing" the event from the rest of the components in the view, by only telling your custom container about it.

In the start of your handler, try this to propagate the event:

 View::handleClickEvent(evt);

/Martin

Yunus ARI
Yunus ARIAuthor
Senior
January 30, 2020

Only now I could find time to try this. Its work properly. Thank You for advice. =)

Just one correction;

 View::handleDragEvent(evt);

I think you wrote "Click" instead "Drag". :)