Gjsify LogoGjsify Logo

A #GdkEvent 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_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;
union

Hierarchy

  • Event

Index

Constructors

Properties

a #GdkEventAny

field

a #GdkEventButton

field
configure: Gdk.EventConfigure

a #GdkEventConfigure

field
crossing: Gdk.EventCrossing

a #GdkEventCrossing

field

a #GdkEventDND

field

a #GdkEventExpose

field
focusChange: Gdk.EventFocus

a #GdkEventFocus

field
grabBroken: Gdk.EventGrabBroken

a #GdkEventGrabBroken

field

a #GdkEventKey

field

a #GdkEventMotion

field
ownerChange: Gdk.EventOwnerChange

a #GdkEventOwnerChange

field
padAxis: EventPadAxis

a #GdkEventPadAxis

field
padButton: EventPadButton

a #GdkEventPadButton

field
padGroupMode: EventPadGroupMode

a #GdkEventPadGroupMode

field
property: Gdk.EventProperty

a #GdkEventProperty

field
proximity: Gdk.EventProximity

a #GdkEventProximity

field

a #GdkEventScroll

field
selection: Gdk.EventSelection

a #GdkEventSelection

field
setting: Gdk.EventSetting

a #GdkEventSetting

field
touch: EventTouch

a #GdkEventTouch

field
touchpadPinch: EventTouchpadPinch

a #GdkEventTouchpadPinch

field
touchpadSwipe: EventTouchpadSwipe

a #GdkEventTouchpadSwipe

field

the #GdkEventType

field
visibility: Gdk.EventVisibility

a #GdkEventVisibility

field
windowState: Gdk.EventWindowState

a #GdkEventWindowState

field
name: string

Methods

  • Copies a #GdkEvent, copying or incrementing the reference count of the resources associated with it (e.g. #GdkWindow’s and strings).

    Returns Gdk.Event

  • free(): void
  • Frees a #GdkEvent, 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

  • getAngle(event2: Gdk.Event): [boolean, number]
  • 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]

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

    Parameters

    Returns [boolean, number]

  • getButton(): [boolean, number]
  • Extract the button number from an event.

    Returns [boolean, number]

  • getCenter(event2: Gdk.Event): [boolean, number, number]
  • If both events contain X/Y information, the center of both coordinates will be returned in x and y.

    Parameters

    Returns [boolean, number, number]

  • getClickCount(): [boolean, number]
  • Extracts the click count from an event.

    Returns [boolean, number]

  • getCoords(): [boolean, number, number]
  • Extract the event window relative x/y coordinates from an event.

    Returns [boolean, number, number]

  • If the event contains a “device” field, this function will return it, else it will return %NULL.

    Returns Gdk.Device

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

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

    Returns Gdk.DeviceTool

  • getDistance(event2: Gdk.Event): [boolean, number]
  • 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]

  • If event if of type %GDK_TOUCH_BEGIN, %GDK_TOUCH_UPDATE, %GDK_TOUCH_END or %GDK_TOUCH_CANCEL, returns the #GdkEventSequence to which the event belongs. Otherwise, return %NULL.

    Returns Gdk.EventSequence

  • getKeycode(): [boolean, number]
  • Extracts the hardware keycode from an event.

    Also see gdk_event_get_scancode().

    Returns [boolean, number]

  • getKeyval(): [boolean, number]
  • Extracts the keyval from an event.

    Returns [boolean, number]

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

    Returns boolean

  • getRootCoords(): [boolean, number, number]
  • Extract the root window relative x/y coordinates from an event.

    Returns [boolean, number, number]

  • getScancode(): number
  • 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

  • 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

  • getScrollDeltas(): [boolean, number, number]
  • Retrieves the scroll deltas from a #GdkEvent

    See also: gdk_event_get_scroll_direction()

    Returns [boolean, number, number]

  • 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;
    }

    Returns [boolean, Gdk.ScrollDirection]

  • This function returns the hardware (slave) #GdkDevice 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 #GdkWindow 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

  • 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]

  • getTime(): number
  • 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

  • isScrollStopEvent(): boolean
  • 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

  • put(): void
  • 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

  • Sets the device for event to device. The event must have been allocated by GTK+, for instance, by gdk_event_copy().

    Parameters

    Returns void

  • Sets the device tool for this event, should be rarely used.

    Parameters

    Returns void

  • Sets the screen for event to screen. The event must have been allocated by GTK+, for instance, by gdk_event_copy().

    Parameters

    Returns void

  • Sets the slave device for event to device.

    The event must have been allocated by GTK+, for instance by gdk_event_copy().

    Parameters

    Returns void

  • triggersContextMenu(): boolean
  • This function returns whether a #GdkEventButton 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_MODIFIER_INTENT_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

  • Checks all open displays for a #GdkEvent to process,to be processed on, fetching events from the windowing system if necessary. See gdk_display_get_event().

    Returns Gdk.Event

  • 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: Gdk.EventFunc

      the function to call to handle events from GDK.

    Returns void

  • If there is an event waiting in the event queue of some open display, returns a copy of it. See gdk_display_peek_event().

    Returns Gdk.Event

  • 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_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

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method