Class (GI Struct)

Gdk-3.0GdkEvent

A Gdk.Event contains a union of all of the event types, and allows access to the data fields in a number of ways.

The event type is always the first field in all of the event types, and can always be accessed with the following code, no matter what type of event it is:

  GdkEvent *event;
GdkEventType type;

type = event->type;

To access other fields of the event, the pointer to the event can be cast to the appropriate event type, or the union member name can be used. For example if the event type is Gdk.EventType.BUTTON_PRESS then the x coordinate of the button press can be accessed with:

  GdkEvent *event;
gdouble x;

x = ((GdkEventButton*)event)->x;

or:

  GdkEvent *event;
gdouble x;

x = event->button.x;
Index

Constructors

Properties

$gtype: GType<Gdk.Event>

Methods

  • If both events contain X/Y information, this function will return true and return in angle the relative angle from event1 to event2. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.

    Parameters

    Returns [boolean, number]

    true if the angle could be calculated.

  • If both events contain X/Y information, the center of both coordinates will be returned in x and y.

    Parameters

    Returns [boolean, number, number]

    true if the center could be calculated.

  • If both events have X/Y information, the distance between both coordinates (as in a straight line going from event1 to event2) will be returned.

    Parameters

    Returns [boolean, number]

    true if the distance could be calculated.

  • Frees a Gdk.Event, freeing or decrementing any resources associated with it. Note that this function should only be called with events returned from functions such as gdk_event_peek(), gdk_event_get(), gdk_event_copy() and gdk_event_new().

    Returns void

  • Extract the axis value for a particular axis use from an event structure.

    Parameters

    Returns [boolean, number]

    true if the specified axis was found, otherwise false

  • Extract the button number from an event.

    Returns [boolean, number]

    true if the event delivered a button number

  • Extracts the click count from an event.

    Returns [boolean, number]

    true if the event delivered a click count

  • Extract the event window relative x/y coordinates from an event.

    Returns [boolean, number, number]

    true if the event delivered event window coordinates

  • If the event was generated by a device that supports different tools (eg. a tablet), this function will return a Gdk.DeviceTool representing the tool that caused the event. Otherwise, null will be returned.

    Note: the Gdk.DeviceTools will be constant during the application lifetime, if settings must be stored persistently across runs, see gdk_device_tool_get_serial()

    Returns Gdk.DeviceTool

    The current device tool, or null

  • Extracts the hardware keycode from an event.

    Also see gdk_event_get_scancode().

    Returns [boolean, number]

    true if the event delivered a hardware keycode

  • Extracts the keyval from an event.

    Returns [boolean, number]

    true if the event delivered a key symbol

  • #event: a Gdk.Event Returns whether this event is an 'emulated' pointer event (typically from a touch event), as opposed to a real one.

    Returns boolean

    true if this event is emulated

  • Extract the root window relative x/y coordinates from an event.

    Returns [boolean, number, number]

    true if the event delivered root window coordinates

  • Gets the keyboard low-level scancode of a key event.

    This is usually hardware_keycode. On Windows this is the high word of WM_KEY{DOWN,UP} lParam which contains the scancode and some extended flags.

    Returns number

    The associated keyboard scancode or 0

  • Returns the screen for the event. The screen is typically the screen for event->any.window, but for events such as mouse events, it is the screen where the pointer was when the event occurs - that is, the screen which has the root window to which event->motion.x_root and event->motion.y_root are relative.

    Returns Gdk.Screen

    the screen for the event

  • Retrieves the scroll deltas from a Gdk.Event

    See also: gdk_event_get_scroll_direction()

    Returns [boolean, number, number]

    true if the event contains smooth scroll information and false otherwise

  • Extracts the scroll direction from an event.

    If event is not of type Gdk.EventType.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;
    }

    Returns [boolean, Gdk.ScrollDirection]

    true if the event delivered a scroll direction and false otherwise

  • This function returns the hardware (slave) Gdk.Device that has triggered the event, falling back to the virtual (master) device (as in gdk_event_get_device()) if the event wasn’t caused by interaction with a hardware device. This may happen for example in synthesized crossing events after a Gdk.Window updates its geometry or a grab is acquired/released.

    If the event does not contain a device field, this function will return null.

    Returns Gdk.Device

    a Gdk.Device, or null.

  • If the event contains a “state” field, puts that field in state. Otherwise stores an empty state (0). Returns true if there was a state field in the event. event may be null, in which case it’s treated as if the event had no state field.

    Returns [boolean, Gdk.ModifierType]

    true if there was a state field in the event

  • Returns the time stamp from event, if there is one; otherwise returns #GDK_CURRENT_TIME. If event is null, returns #GDK_CURRENT_TIME.

    Returns number

    time stamp field from event

  • Check whether a scroll event is a stop scroll event. Scroll sequences with smooth scroll information may provide a stop scroll event once the interaction with the device finishes, e.g. by lifting a finger. This stop scroll event is the signal that a widget may trigger kinetic scrolling based on the current velocity.

    Stop scroll events always have a a delta of 0/0.

    Returns boolean

    true if the event is a scroll stop event

  • Appends a copy of the given event onto the front of the event queue for event->any.window’s display, or the default event queue if event->any.window is null. See gdk_display_put_event().

    Returns void

  • This function returns whether a Gdk.EventButton should trigger a context menu, according to platform conventions. The right mouse button always triggers context menus. Additionally, if gdk_keymap_get_modifier_mask() returns a non-0 mask for Gdk.ModifierIntent.CONTEXT_MENU, then the left mouse button will also trigger a context menu if this modifier is pressed.

    This function should always be used instead of simply checking for event->button == GDK_BUTTON_SECONDARY.

    Returns boolean

    true if the event should trigger a context menu.

  • Sets the function to call to handle all events from GDK.

    Note that GTK+ uses this to install its own event handler, so it is usually not useful for GTK+ applications. (Although an application can call this function then call gtk_main_do_event() to pass events to GTK+.)

    Parameters

    • func: EventFunc

      the function to call to handle events from GDK.

    Returns void

  • Request more motion notifies if event is a motion notify hint event.

    This function should be used instead of gdk_window_get_pointer() to request further motion notifies, because it also works for extension events where motion notifies are provided for devices other than the core pointer. Coordinate extraction, processing and requesting more motion events from a Gdk.EventType.MOTION_NOTIFY event usually works like this:

    {
    // motion_event handler
    x = motion_event->x;
    y = motion_event->y;
    // handle (x,y) motion
    gdk_event_request_motions (motion_event); // handles is_hint events
    }

    Parameters

    Returns void