Skip to main content
Senior
April 20, 2022
Question

handleGestureEvent in Screen class

  • April 20, 2022
  • 3 replies
  • 1236 views

I'm trying to use handleGestureEvent in Screen.

But handleClickEvent and handleDragEvent are called correctly, and handleGestureEvent it is never shouted!

Should the "fire" of this event in the Screen class be activated in some way. I could not find anything in the documentation of TouchGFX

class ScreenView : public ScreenViewBase
{
 
public:
 
// .... // 
 
 auto handleGestureEvent (const GestureEvent & event) -> void override
 {
 ScreenViewBase::handleGestureEvent (event);
 }
 
 auto handleClickEvent (const ClickEvent & event) -> void override
 {
 ScreenViewBase::handleClickEvent (event);
 }
 
 auto handleDragEvent (const DragEvent & event) -> void override
 {
 ScreenViewBase::handleDragEvent (event);
 }
};

This topic has been closed for replies.

3 replies

Osman SOYKURT
ST Technical Moderator
April 20, 2022

Hello Panchev68,

handleGestureEvent can be triggered with a "swipe" event. You can use it like that :

in your Screen1View.hpp

class Screen1View : public Screen1ViewBase
{
public:
// ... //
 virtual void handleGestureEvent(const GestureEvent& event);
};

in your Screen1View.cpp

void Screen1View::handleGestureEvent(const GestureEvent& event)
{ 
// action to be done
}

You'll find attached an example of a project using that GestureEvent :)

/Osman

ST Software Developer | TouchGFX
Panchev68Author
Senior
April 20, 2022

Thanks for the quick response and support !!!

As you can see, I'm doing exactly the same thing in my example. But even in the simulator in your project, the event is generated quite chaotically. Maybe I'm wrong in my approach. I expected that in case of "swipe" on the screen will call handleGestureEvent, as happens with handleClickEvent and handleDragEvent, but this is not true.

The handleGestureEvent is sometimes called only on a screen that has control that it uses with gesture. It is practically unusable, for example, for switching gesture screens. I tried it in my project and it works the same way as with you.

Osman SOYKURT
ST Technical Moderator
April 21, 2022

Yes, it can be hard to produce the event on the simulator. The way I do it is like I click with my mouse while moving it fast, I don't keep it pressed. Like as fast scrolling on your smartphone.

/Osman

ST Software Developer | TouchGFX