주요 내용으로 건너뛰기

Snapper

A mix-in that will make class T draggable and able to snap to a position when a drag operation has ended. The mix-in is able to perform callbacks when the snapper gets dragged and when the Snapper snaps to its snap position.

Template Parameters:

  • T specifies the type to enable the Snap behavior to.

See: Draggable<T>

Inherits from: touchgfx::Draggable< T >, T

Public Functions

virtual voidhandleClickEvent(const ClickEvent & event)
Handles the click events when the Snapper is clicked.
virtual voidhandleDragEvent(const DragEvent & event)
Called when dragging the Draggable object.
voidsetDragAction(GenericCallback< const DragEvent & > & callback)
Associates an action to be performed when the Snapper is dragged.
voidsetSnappedAction(GenericCallback<> & callback)
Associates an action to be performed when the Snapper is snapped.
voidsetSnapPosition(int16_t x, int16_t y)
Sets the position the Snapper should snap to.
Snapper()

Additional inherited members

Public Functions inherited from touchgfx::Draggable< T >

Draggable()
Initializes a new instance of the Draggable class.

Public Functions Documentation

handleClickEvent

virtual void handleClickEvent(const ClickEvent &event)

Handles the click events when the Snapper is clicked.

It saves its current position as the snap position if the Snapper is pressed. This happens when the drag operation starts.

The snapper will then move to the snap position when the click is released. This happens when the drag operation ends.

Parameters:
eventThe click event.

handleDragEvent

virtual void handleDragEvent(const DragEvent &event)

Called when dragging the Draggable object.

The object is moved according to the drag event.

Parameters:
eventThe drag event.

Reimplements: touchgfx::Draggable::handleDragEvent

setDragAction

void setDragAction(GenericCallback< const DragEvent & > &callback)

Associates an action to be performed when the Snapper is dragged.

Parameters:
callbackThe callback will be executed with the DragEvent.
See also:

setSnappedAction

Associates an action to be performed when the Snapper is snapped.

Parameters:
callbackThe callback to be executed on snap.
See also:

setSnapPosition

void setSnapPosition(int16_tx ,
int16_ty
)

Sets the position the Snapper should snap to.

This position will be overridden with the Snappers current position when the Snapper is pressed.

Parameters:
xThe x coordinate.
yThe y coordinate.

Snapper