CtkGestureDrag: CTK+ 3 Reference Manual

## CtkGestureDrag CtkGestureDrag — Drag gesture |

## Functions

CtkGesture * | ctk_gesture_drag_new ()
gboolean | ctk_gesture_drag_get_start_point ()
gboolean | ctk_gesture_drag_get_offset ()

## Signals

void | drag-begin | Run Last
void | drag-end | Run Last
void | drag-update | Run Last

## Types and Values

| CtkGestureDrag

## Object Hierarchy

        GObject
        ╰── CtkEventController
            ╰── CtkGesture
                ╰── CtkGestureSingle
                    ╰── CtkGestureDrag
                        ╰── CtkGesturePan

## Includes

    #include <ctk/ctk.h>

## Description

CtkGestureDrag is a CtkGesture implementation that recognizes drag operations. The drag operation itself can be tracked throught the “drag-begin”, “drag-update” and “drag-end” signals, or the relevant coordinates be extracted through `ctk_gesture_drag_get_offset()` and `ctk_gesture_drag_get_start_point()`.

## Functions

### ctk_gesture_drag_new ()

    CtkGesture *
    ctk_gesture_drag_new (CtkWidget *widget);

Returns a newly created CtkGesture that recognizes drags.

#### Parameters

widget | a CtkWidget |

#### Returns

a newly created CtkGestureDrag

Since: 3.14

### ctk_gesture_drag_get_start_point ()

    gboolean
    ctk_gesture_drag_get_start_point (CtkGestureDrag *gesture,
                                      gdouble *x,
                                      gdouble *y);

If the `gesture` is active, this function returns `TRUE` and fills in `x` and `y` with the drag start coordinates, in window-relative coordinates.

#### Parameters

gesture | a CtkGesture |
x | X coordinate for the drag start point. | [out][nullable]
y | Y coordinate for the drag start point. | [out][nullable]

#### Returns

`TRUE` if the gesture is active

Since: 3.14

### ctk_gesture_drag_get_offset ()

    gboolean
    ctk_gesture_drag_get_offset (CtkGestureDrag *gesture,
                                 gdouble *x,
                                 gdouble *y);

If the `gesture` is active, this function returns `TRUE` and fills in `x` and `y` with the coordinates of the current point, as an offset to the starting drag point.

#### Parameters

gesture | a CtkGesture |
x | X offset for the current point. | [out][nullable]
y | Y offset for the current point. | [out][nullable]

#### Returns

`TRUE` if the gesture is active

Since: 3.14

## Types and Values

### CtkGestureDrag

    typedef struct _CtkGestureDrag CtkGestureDrag;

## Signal Details

### The `“drag-begin”` signal

    void
    user_function (CtkGestureDrag *gesture,
                   double          start_x,
                   double          start_y,
                   gpointer        user_data)

This signal is emitted whenever dragging starts.

#### Parameters

gesture | the object which received the signal |
start_x | X coordinate, relative to the widget allocation |
start_y | Y coordinate, relative to the widget allocation |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

Since: 3.14

### The `“drag-end”` signal

    void
    user_function (CtkGestureDrag *gesture,
                   double          offset_x,
                   double          offset_y,
                   gpointer        user_data)

This signal is emitted whenever the dragging is finished.

#### Parameters

gesture | the object which received the signal |
offset_x | X offset, relative to the start point |
offset_y | Y offset, relative to the start point |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

Since: 3.14

### The `“drag-update”` signal

    void
    user_function (CtkGestureDrag *gesture,
                   double          offset_x,
                   double          offset_y,
                   gpointer        user_data)

This signal is emitted whenever the dragging point moves.

#### Parameters

gesture | the object which received the signal |
offset_x | X offset, relative to the start point |
offset_y | Y offset, relative to the start point |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

Since: 3.14

## See Also

CtkGestureSwipe