cancel
Showing results for 
Search instead for 
Did you mean: 

Don't know how to inherit handleClickEvent()

Iñaki_Bidasoro
Associate III

Hi I have a scrollable container inside a swipe container and i need to check when the drag is horizontal and when it's vertical so that I can channel the event to the one i want it to handle with, this was discussed and resolved in this post:
https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/swiping-and-scrolling/td-p/238053

But I have tried to implement it, changing the variable names but I have the following problems

  • Even though I have declared the classes in my view.hpp it says that the cpp cant see them, so i was wondering that maybe im doing it wrong, also i have tried to look for the functions in the upwards inheritance of the viewbase class but i couldnt find it, i saw that the classes like container do have it as they come from drawable.

 

  • the variable dragType is not found either, and this one I couldnt find anywhere, so maybe he created it but im not sure as it looks like a touchgfx variable.

This is how i have declared the functions in the view.hpp

 

 

 

class VacuumFunctionsView : public VacuumFunctionsViewBase
{
public:
    VacuumFunctionsView();
    virtual ~VacuumFunctionsView() {}
    virtual void setupScreen();
    virtual void tearDownScreen();

    virtual void customizeToggles();

protected:
    bool isListClicked;

    virtual void handleClickEvent(const ClickEvent& evt){}
    virtual void handleDragEvent(const DragEvent& evt){}
    virtual void handleGestureEvent(const GestureEvent& evt){}

 

And this is how i have implemented it in the cpp

 

void VacuumFunctionsView::handleClickEvent(const ClickEvent& evt)
{
    if (evt.getType() == ClickEvent::PRESSED)
    {
        if(scrollProducts.getAbsoluteRect().intersect(evt.getX(), evt.getY()))
        {
            isListClicked = true;
        }
    }
    else if (evt.getType() == ClickEvent::RELEASED)
    {
        dragType = NONE;
    }

    if(dragType != VERTICAL) //The swipe container should handle the event
    {
        swipeContainer.handleClickEvent(evt);
    }
    VacuumFunctionsViewBase::handleClickEvent(evt);
}

void VacuumFunctionsView::handleDragEvent(const DragEvent& evt)
{
    if(isListClicked)
    {
        isListClicked = false;
        if(abs(evt.getDeltaY()) < abs(evt.getDeltaX()))
        {
            dragType = HORIZONTAL;
        }
        else
        {
            dragType = VERTICAL;
        }
    }
    else
    {
        if(dragType == HORIZONTAL) //The swipe container should handle the event
        {
            swipeContainer.handleDragEvent(evt);
        }
        else //The scroll container or the view should handle the event
        {
            VacuumFunctionsViewBase::handleDragEvent(evt);
        }
    }
}

void VacuumFunctionsView::handleGestureEvent(const GestureEvent& evt)
{
    if(dragType == HORIZONTAL) //The swipe container should handle the event
    {
        swipeContainer.handleGestureEvent(evt);
    }
    else //The scroll container or the view should handle the event
    {
        VacuumFunctionsViewBase::handleGestureEvent(evt);
    }
}

 

1 ACCEPTED SOLUTION

Accepted Solutions
JTP1
Lead

Hello Iñaki

Its bit difficult to understand completely your problem, but lets try.


 


@Iñaki_Bidasoro wrote:
Even though I have declared the classes in my view.hpp it says that the cpp cant see them, so i was wondering that maybe im doing it wrong, also i have tried to look for the functions in the upwards inheritance of the viewbase class but i couldnt find it, i saw that the classes like container do have it as they come from drawable.

 Seems that you are allready defining functions to empty... test like this in .hpp:

    virtual void handleClickEvent(const ClickEvent& evt);
    virtual void handleDragEvent(const DragEvent& evt);
    virtual void handleGestureEvent(const GestureEvent& evt);

//Instead of
//    virtual void handleClickEvent(const ClickEvent& evt){}
//    virtual void handleDragEvent(const DragEvent& evt){}
//    virtual void handleGestureEvent(const GestureEvent& evt){}

 


@Iñaki_Bidasoro wrote:
  • the variable dragType is not found either, and this one I couldnt find anywhere, so maybe he created it but im not sure as it looks like a touchgfx variable.

For me it looks like just user-defined enumerated variable where dragging state is stored so I would add something like this to view.hpp

	enum dragTypeEnum 
    {
        NONE,  
        HORIZONTAL, 
        VERTICAL    
    };
	dragTypeEnum dragType=NONE;

 Maybe this helps you:thumbs_up:

Br JTP

View solution in original post

2 REPLIES 2
JTP1
Lead

Hello Iñaki

Its bit difficult to understand completely your problem, but lets try.


 


@Iñaki_Bidasoro wrote:
Even though I have declared the classes in my view.hpp it says that the cpp cant see them, so i was wondering that maybe im doing it wrong, also i have tried to look for the functions in the upwards inheritance of the viewbase class but i couldnt find it, i saw that the classes like container do have it as they come from drawable.

 Seems that you are allready defining functions to empty... test like this in .hpp:

    virtual void handleClickEvent(const ClickEvent& evt);
    virtual void handleDragEvent(const DragEvent& evt);
    virtual void handleGestureEvent(const GestureEvent& evt);

//Instead of
//    virtual void handleClickEvent(const ClickEvent& evt){}
//    virtual void handleDragEvent(const DragEvent& evt){}
//    virtual void handleGestureEvent(const GestureEvent& evt){}

 


@Iñaki_Bidasoro wrote:
  • the variable dragType is not found either, and this one I couldnt find anywhere, so maybe he created it but im not sure as it looks like a touchgfx variable.

For me it looks like just user-defined enumerated variable where dragging state is stored so I would add something like this to view.hpp

	enum dragTypeEnum 
    {
        NONE,  
        HORIZONTAL, 
        VERTICAL    
    };
	dragTypeEnum dragType=NONE;

 Maybe this helps you:thumbs_up:

Br JTP

Thank you that was it!