2022-01-26 11:09 PM
I have a MainView that has a member Swipe containter.
class MainViewBase : public touchgfx::View<MainPresenter>
{
public:
MainViewBase();
virtual ~MainViewBase() {}
virtual void setupScreen();
protected:
FrontendApplication& application() {
return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance());
}
/*
* Member Declarations
*/
touchgfx::SwipeContainer swipeContainer;
Every swipeContainer has a virtual method handleDragEvent
class SwipeContainer : public Container
{
public:
SwipeContainer();
virtual ~SwipeContainer();
virtual void handleTickEvent();
virtual void handleClickEvent(const ClickEvent& event);
virtual void handleDragEvent(const DragEvent& event);
virtual void handleGestureEvent(const GestureEvent& event);
I would like to implement a slideMenu expansion when swipe cointainer detects drag in Y direction. Where can I overide handleDragEvent of this swipeContainer and redefine what I want?
2022-02-23 01:41 AM
Hello @manto.1 ,
Like you said, the SwipeContainer member is called in the MainViewBase class.
Since the MainView class derives from the MainViewBase class, you can easily access and override the MainViewBase class members and methods in your MainView class :
void handleDragEvent(const DragEvent& event) override;
void MainView::handleDragEvent(const DragEvent& event)
{
}
Then, every time the user will drag the SwipeContainer, this method will be called.
You will be able to easily access to X and Y coordinates and/or dragging directions on the screen, thanks to the methods implemented in the DragEvent class, e.g. getDeltaY()(https://support.touchgfx.com/4.18/docs/api/classes/classtouchgfx_1_1_drag_event).
Hope that this helped,
/Yoann