Method

GdkEventget_scroll_direction

Declaration [src]

gboolean
gdk_event_get_scroll_direction (
  const GdkEvent* event,
  GdkScrollDirection* direction
)

Description [src]

Extracts the scroll direction from an event.

If event is not of type GDK_SCROLL, the contents of direction are undefined.

If you wish to handle both discrete and smooth scrolling, you should check the return value of this function, or of gdk_event_get_scroll_deltas(); for instance:

  GdkScrollDirection direction;
  double vscroll_factor = 0.0;
  double x_scroll, y_scroll;

  if (gdk_event_get_scroll_direction (event, &direction))
    {
      // Handle discrete scrolling with a known constant delta;
      const double delta = 12.0;

      switch (direction)
        {
        case GDK_SCROLL_UP:
          vscroll_factor = -delta;
          break;
        case GDK_SCROLL_DOWN:
          vscroll_factor = delta;
          break;
        default:
          // no scrolling
          break;
        }
    }
  else if (gdk_event_get_scroll_deltas (event, &x_scroll, &y_scroll))
    {
      // Handle smooth scrolling directly
      vscroll_factor = y_scroll;
    }
Available since:3.2

Parameters

direction

Type: GdkScrollDirection

Location to store the scroll direction.

The argument will be set by the function.
The instance takes ownership of the data, and is responsible for freeing it.

Return value

Type: gboolean

TRUE if the event delivered a scroll direction and FALSE otherwise.