Skip to main content
January 19, 2021
Question

GEsture Event not works

  • January 19, 2021
  • 8 replies
  • 1242 views

My HPP

#ifndef PRINT_PROGRESS_SCREENVIEW_HPP
#define PRINT_PROGRESS_SCREENVIEW_HPP
 
#include <gui_generated/print_progress_screen_screen/PRINT_PROGRESS_ScreenViewBase.hpp>
#include <gui/print_progress_screen_screen/PRINT_PROGRESS_ScreenPresenter.hpp>
 
class PRINT_PROGRESS_ScreenView : public PRINT_PROGRESS_ScreenViewBase
{
public:
 PRINT_PROGRESS_ScreenView();
 virtual ~PRINT_PROGRESS_ScreenView() {}
 virtual void setupScreen();
 virtual void tearDownScreen();
				
			void handleTickEvent();
			
			virtual void handleClickEvent(const ClickEvent& evt);
			virtual void handleGestureEvent(const GestureEvent& evt); 
			virtual void DRAW_function();
			virtual void ScreenEntered_function();
			
protected:
	Callback<PRINT_PROGRESS_ScreenView, const BoxWithBorder&, const ClickEvent&> Box3DClickedCallback; 
 Callback<PRINT_PROGRESS_ScreenView, const BoxWithBorder&, const GestureEvent&> Box3DGestureCallback; 
 
void Box3DClickHandler(const BoxWithBorder& b, const ClickEvent& e);
void Box3DGestureHandler(const BoxWithBorder& b, const GestureEvent& g);
};
 
#endif // PRINT_PROGRESS_SCREENVIEW_HPP

My CPP

PRINT_PROGRESS_ScreenView::PRINT_PROGRESS_ScreenView():
Box3DClickedCallback(this, &PRINT_PROGRESS_ScreenView::Box3DClickHandler), 
Box3DGestureCallback(this, &PRINT_PROGRESS_ScreenView::Box3DGestureHandler) 	
{
 
}
 
void PRINT_PROGRESS_ScreenView::setupScreen()
{
 PRINT_PROGRESS_ScreenViewBase::setupScreen();
		Box3D.setClickAction(Box3DClickedCallback);
	 
		
		
}
 
void PRINT_PROGRESS_ScreenView::tearDownScreen()
{
 PRINT_PROGRESS_ScreenViewBase::tearDownScreen();
}
 
.....................................
 
void PRINT_PROGRESS_ScreenView::Box3DGestureHandler(const BoxWithBorder& b, const GestureEvent& g_evt)
{
 if (&b == &Box3D)
 {
 //Implement what should happen when 'box' is touched/clicked here.
			if(g_evt.getType() == GestureEvent::SWIPE_VERTICAL)
				{
					
			
 
					
		// Do something with x and y, such as...
					//		presenter->touchRegistered(x, y); // you write this function in the presenter
				}
 }
}

I try to swipe on Box3D (clickListener is on)

But Box3DGestureHandler - never called....

How to do?

This topic has been closed for replies.

8 replies

MM..1
Super User
January 19, 2021
January 19, 2021

There's no any useful information about my problem

MM..1
Super User
January 19, 2021

try implement this in cpp

virtual void handleGestureEvent(const GestureEvent& evt);

and place breakpoint in.

and maybe add name in hpp

protected:
	touchgfx::Callback<PRINT_PROGRESS_ScreenView, const BoxWithBorder&, const ClickEvent&> Box3DClickedCallback; 
 touchgfx::Callback<PRINT_PROGRESS_ScreenView, const BoxWithBorder&, const GestureEvent&> Box3DGestureCallback;

January 20, 2021

This is my cpp

#include 
#include "dsp3D.h"
 
extern DMA2D_HandleTypeDef hdma2d;
 
extern uint32_t tick_counter;
extern uint32_t touch_address;
extern float32_t meshRotation[3];
 
extern uint32_t xx,yyy;
 
 
 extern uint16_t x_from;
	extern uint16_t y_from;
	extern uint16_t x_to;
	extern uint16_t y_to;
	extern uint16_t region_width;
	extern uint16_t region_height;
 
uint32_t adr;
 
uint32_t old_x,old_y,new_x,new_y;
 
uint32_t tft_buffer_number;
uint8_t FRAME_COMPLETE;
 
float32_t dsp3dModel2[218] = {24, 12,
-1, 1, 1, 0, -1, 0,//0
1, 1, 1, 0, -1, 0,
1, 1, -1, 0, -1, 0,
-1, 1, -1, 0, -1, 0,
-1, -1, 1, 0, 1, 0,//4
1, -1, 1, 0, 1, 0,
1, -1, -1, 0, 1, 0,
-1, -1, -1, 0, 1, 0,
1, -1, 1, -1, 0, 0, //8
1, -1, -1, -1, 0, 0,
1, 1, -1, -1, 0, 0,
1, 1, 1, -1, 0, 0,
-1, -1, 1, 1, 0, 0, //12
-1, -1, -1, 1, 0, 0,
-1, 1, -1, 1, 0, 0,
-1, 1, 1, 1, 0, 0,
-1, -1, 1, 0, 0, -1, //16
1, -1, 1, 0, 0, -1,
1, 1, 1, 0, 0, -1,
-1, 1, 1, 0, 0, -1,
-1, -1, -1, 0, 0, 1, //20
1, -1, -1, 0, 0, 1,
1, 1, -1, 0, 0, 1,
-1, 1, -1, 0, 0, 1,
 
0, 1, 2, 255, 0, 0,
3, 0, 2, 255, 0, 0,
6, 5, 4, 255, 0, 0,
6, 4, 7, 255, 0, 0,
8, 9, 10, 0, 255, 0,
11, 8, 10, 255, 255, 0,
14, 13, 12, 255, 0, 0,
14, 12, 15, 255, 0, 0,
16, 17, 18, 255,255,0,
19 ,16, 18, 255, 0,0,
22, 21, 20, 255, 0,0,
22, 20, 23, 255 ,0,0,
};
 
 
PRINT_PROGRESS_ScreenView::PRINT_PROGRESS_ScreenView():
Box3DClickedCallback(this, &PRINT_PROGRESS_ScreenView::Box3DClickHandler), 
Box3DGestureCallback(this, &PRINT_PROGRESS_ScreenView::Box3DGestureHandler) 	
{
 
}
 
void PRINT_PROGRESS_ScreenView::setupScreen()
{
 PRINT_PROGRESS_ScreenViewBase::setupScreen();
		Box3D.setClickAction(Box3DClickedCallback);
	 
		
		
}
 
void PRINT_PROGRESS_ScreenView::tearDownScreen()
{
 PRINT_PROGRESS_ScreenViewBase::tearDownScreen();
}
 
void PRINT_PROGRESS_ScreenView::DRAW_function()
{
 
	
	
		
	
	
	
	if (LTDC_Layer1->CFBAR==0xD0000000) adr=0xD0200000; else adr=0xD0000000;
 
	
	//for(uint16_t x = 502; x CFBAR = (uint32_t)adr;
 
 LTDC->SRCR = (uint32_t)LTDC_SRCR_IMR;
 
 
}	
 
 
void PRINT_PROGRESS_ScreenView::Box3DClickHandler(const BoxWithBorder& b, const ClickEvent& evt)
{
 if (&b == &Box3D)
 {
 
 
 
 
 
			//Implement what should happen when 'box' is touched/clicked here.
			if(evt.getType() == ClickEvent::PRESSED)
				{
					
					int x = evt.getX();
					int y = evt.getY();
						***=x;
						yyy=y;
						touch_address=(yyy*500+***)*4;
				}
					
		// Do something with x and y, such as...
					//		presenter->touchRegistered(x, y); // you write this function in the presenter
//				}
 }
}
 
 
void PRINT_PROGRESS_ScreenView::Box3DGestureHandler(const BoxWithBorder& b, const GestureEvent& g_evt)
{
 if (&b == &Box3D)
 {
 //Implement what should happen when 'box' is touched/clicked here.
			if(g_evt.getType() == GestureEvent::SWIPE_VERTICAL)
				{
					
					//old_x = d_evt.getOldX();
					//old_y = d_evt.getOldY();
					//new_x = d_evt.getNewX();
					//new_y = d_evt.getNewY();
 
 
					
		// Do something with x and y, such as...
					//		presenter->touchRegistered(x, y); // you write this function in the presenter
				}
 }
}
 
void PRINT_PROGRESS_ScreenView::handleClickEvent(const ClickEvent& evt)
{
 View::handleClickEvent(evt);
}
 
 void PRINT_PROGRESS_ScreenView::handleGestureEvent(const GestureEvent& evt) 
 { 
xx++;
 }
 
void PRINT_PROGRESS_ScreenView::handleTickEvent()
{
	
	tick_counter++;
 
 
 
		if (tick_counter>300)
		{	
			tick_counter=0;
		}	
 
///Application::getInstance()->registerTimerWidget(this); // ЭТО ЕСЛИ ВДРУГ ПО�?�?ДОБИТСЯ ЛОВИТЬ Т�?КТЫ Т�?ЙМЕР�? В CONTAINER
 
}	
 
 
void PRINT_PROGRESS_ScreenView::ScreenEntered_function()
{
FRAME_COMPLETE=1;
	SCB_CleanInvalidateDCache();
		hdma2d.Init.Mode = DMA2D_M2M;
		hdma2d.Init.OutputOffset =1024-495;
		hdma2d.Init.ColorMode = DMA2D_OUTPUT_RGB888;
		hdma2d.LayerCfg[1].InputOffset = 1024-495;
	 hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB888;	
		//hdma2d.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
		//hdma2d.LayerCfg[1].InputAlpha = 0;
		HAL_DMA2D_ConfigLayer(&hdma2d, 1);
 	HAL_DMA2D_Init(&hdma2d);
		if(HAL_DMA2D_Start(&hdma2d, LTDC_Layer1->CFBAR+3*(76*1024+502), 0xD0758000,	495, 445) == HAL_OK)
		{
			HAL_DMA2D_PollForTransfer(&hdma2d, 10);
		}
SCB_CleanInvalidateDCache();
}

January 20, 2021

doesn't anyone know? handleClickEvent and handleGestureEvent are initialized exactly the same way. but Gesture is not called....

MM..1
Super User
January 20, 2021

try add drag handler

January 21, 2021

OK, handleDragEvent works, but it called when drag occured in any region of screen. How to connect this handler to one widget, to one boxWithBOrders, for example&