cancel
Showing results for 
Search instead for 
Did you mean: 

Discard GestureEvent on Slider

KMili
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III
/**
     * @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

View solution in original post

2 REPLIES 2
Martin KJELDSEN
Chief III

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
Chief III
/**
     * @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