Skip to main content
KMili
Associate III
October 7, 2019
Solved

Discard GestureEvent on Slider

  • October 7, 2019
  • 2 replies
  • 817 views

Hi,

I have a slider added on View. Also, my view overriders handleGestureEvent to handle it globally. Do you have any idea how to discard gesture event, when I quickly move slider?

Same problem when My FrontendApplication overrides handleGestureEvent.

This topic has been closed for replies.
Best answer by Martin KJELDSEN
/**
 * @fn virtual void Drawable::handleDragEvent(const DragEvent& evt)
 *
 * @brief Defines the event handler interface for DragEvents.
 *
 * Defines the event handler interface for DragEvents. The event is only received if
 * the drawable is touchable.
 *
 * @param evt The DragEvent received from the HAL.
 */
 virtual void handleDragEvent(const DragEvent& evt) { }

Concretely, in your view (having declared handleDragEvent() in MyView.hpp) - Something like this:

void MyView::handleDragEvent(const DragEvent& evt)
{ 
 drag_x = evt.getDeltaX();
 if(drag_x < drag_threshhold)
 {
 View::handleDragEvent(evt);
 }
 }

/Martin

2 replies

Martin KJELDSEN
Principal III
October 7, 2019

Hi @KMili​,

If you override your handleDragEvent() method in the view you can see the delta moved between ticks. If that delta is sufficiently large, the drag must've been quite fast - Then do not forward it to the slider.

/Martin

Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
October 7, 2019
/**
 * @fn virtual void Drawable::handleDragEvent(const DragEvent& evt)
 *
 * @brief Defines the event handler interface for DragEvents.
 *
 * Defines the event handler interface for DragEvents. The event is only received if
 * the drawable is touchable.
 *
 * @param evt The DragEvent received from the HAL.
 */
 virtual void handleDragEvent(const DragEvent& evt) { }

Concretely, in your view (having declared handleDragEvent() in MyView.hpp) - Something like this:

void MyView::handleDragEvent(const DragEvent& evt)
{ 
 drag_x = evt.getDeltaX();
 if(drag_x < drag_threshhold)
 {
 View::handleDragEvent(evt);
 }
 }

/Martin