Skip to main content
Associate II
May 9, 2024
Solved

Don't know how to inherit handleClickEvent()

  • May 9, 2024
  • 1 reply
  • 1167 views

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);
 }
}

 

This topic has been closed for replies.
Best answer by JTP1

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

1 reply

JTP1Best answer
Graduate II
May 11, 2024

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

Associate II
May 13, 2024

Thank you that was it!