Hi @Breeze,
What do you mean by "Want to use a gesture", exactly? What kind of gesture? TouchGFX does not support "gestures", in the classic sense, except swipe. You have some handlers available to you:
/**
* @fn virtual void Drawable::handleDragEvent(const DragEvent& evt)
*
* @brief Defines the event handler interface for DragEvents.
*
* Defines the event handler interface for DragEvents. The event is only received if
* the drawable is touchable.
*
* @param evt The DragEvent received from the HAL.
*/
virtual void handleDragEvent(const DragEvent& evt) { }
/**
* @fn virtual void Drawable::handleClickEvent(const ClickEvent& evt)
*
* @brief Defines the event handler interface for ClickEvents.
*
* Defines the event handler interface for ClickEvents. The default implementation
* ignores the event. The event is only received if the drawable is touchable.
*
* @param evt The ClickEvent received from the HAL.
*/
virtual void handleClickEvent(const ClickEvent& evt) { }
/**
* @fn virtual void Drawable::handleGestureEvent(const GestureEvent& evt)
*
* @brief Defines the event handler interface for GestureEvents.
*
* Defines the event handler interface for GestureEvents. The default implementation
* ignores the event. The event is only received if the drawable is touchable.
*
* @param evt The GestureEvent received from the HAL.
*/
virtual void handleGestureEvent(const GestureEvent& evt) { }
- handleClickEvent() - event type can be either CLICKED or RELEASED. This method will be called if the touch controller samples a coordinate. It will also be called if you're starting a drag event (CLICKED), and when you finish your dragevent (RELEASED).
- handleDragEvent() - allows you to get the movement delta for x and y between ticks and also the old and new value.
- handleGestureEvent() - TouchGFX HAL uses this when it evaluates touch input to determine if a gesture was performed. The GestureEvent holds the gesturetype.
typedef enum
{
SWIPE_HORIZONTAL, ///< An enum constant representing a horizontal swipe
SWIPE_VERTICAL ///< An enum constant representing a vertical swipe
} GestureType;
In conclusion:
Implement these handlers in your view or in your widgets to see how TouchGFX interprets the touch events you produce. For a simple touch you'll get two calls to handleClickEvent() (screen press/release). For a drag you'll receive at least 3 calls.
- handleClickEvent() - Pressed
- handleDragEvent() - Investigate your newx, newy or even deltas to see what happened.
- handleClickEvent() - Released
The ScrollableContainer and the SwipeContainer (touchgfx\containers\) both use handleGestureEvent() to properly react to swipes.
/Martin