Class: Gdk::Event

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Overview

GdkEvents are immutable data structures, created by GDK to represent windowing system events.

In GTK applications the events are handled automatically by toplevel widgets and passed on to the event controllers of appropriate widgets, so using GdkEvent and its related API is rarely needed.

Instance Method Summary collapse

Instance Method Details

#_get_angle(event2, angle) ⇒ Boolean

Returns the relative angle from event1 to event2.

The relative angle is the angle between the X axis and the line through both events' positions. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.

This assumes that both events have X/Y information. If not, this function returns false.

Parameters:

  • event2 (Gdk::Event)

    second GdkEvent

  • angle (Float)

    return location for the relative angle between both events

Returns:

  • (Boolean)

    true if the angle could be calculated.

#_get_center(event2, x, y) ⇒ Boolean

Returns the point halfway between the events' positions.

This assumes that both events have X/Y information. If not, this function returns false.

Parameters:

  • event2 (Gdk::Event)

    second GdkEvent

  • x (Float)

    return location for the X coordinate of the center

  • y (Float)

    return location for the Y coordinate of the center

Returns:

  • (Boolean)

    true if the center could be calculated.

#_get_distance(event2, distance) ⇒ Boolean

Returns the distance between the event locations.

This assumes that both events have X/Y information. If not, this function returns false.

Parameters:

  • event2 (Gdk::Event)

    second GdkEvent

  • distance (Float)

    return location for the distance

Returns:

  • (Boolean)

    true if the distance could be calculated.

#deviceGdk::Device

Returns the device of an event.

Returns:

#device_toolGdk::DeviceTool

Returns a GdkDeviceTool representing the tool that caused the event.

If the was not generated by a device that supports different tools (such as a tablet), this function will return nil.

Note: the GdkDeviceTool will be constant during the application lifetime, if settings must be stored persistently across runs, see [methodGdk.DeviceTool.get_serial].

Returns:

#displayGdk::Display

Retrieves the display associated to the event.

Returns:

#event_sequenceGdk::EventSequence

Returns the event sequence to which the event belongs.

Related touch events are connected in a sequence. Other events typically don't have event sequence information.

Returns:

  • (Gdk::EventSequence)

    the event sequence that the event belongs to

#event_typeGdk::EventType

Retrieves the type of the event.

Returns:

#get_axes(axes, n_axes) ⇒ Boolean

Extracts all axis values from an event.

To find out which axes are used, use [methodGdk.DeviceTool.get_axes] on the device tool returned by [methodGdk.Event.get_device_tool].

Parameters:

  • axes (Array<Float>)

    the array of values for all axes

  • n_axes (Integer)

    the length of array

Returns:

  • (Boolean)

    true on success, otherwise false

#get_axis(axis_use, value) ⇒ Boolean

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

To find out which axes are used, use [methodGdk.DeviceTool.get_axes] on the device tool returned by [methodGdk.Event.get_device_tool].

Parameters:

  • axis_use (Gdk::AxisUse)

    the axis use to look for

  • value (Float)

    location to store the value found

Returns:

  • (Boolean)

    true if the specified axis was found, otherwise false

#get_history(out_n_coords) ⇒ Array<Gdk::TimeCoord>

Retrieves the history of the device that event is for, as a list of time and coordinates.

The history includes positions that are not delivered as separate events to the application because they occurred in the same frame as event.

Note that only motion and scroll events record history, and motion events do it only if one of the mouse buttons is down, or the device has a tool.

Parameters:

  • out_n_coords (Integer)

    Return location for the length of the returned array

Returns:

  • (Array<Gdk::TimeCoord>)

    an array of time and coordinates

#get_position(x, y) ⇒ Boolean

Extract the event surface relative x/y coordinates from an event.

This position is in surface coordinates.

Parameters:

  • x (Float)

    location to put event surface x coordinate

  • y (Float)

    location to put event surface y coordinate

Returns:

  • (Boolean)

#modifier_stateGdk::ModifierType

Returns the modifier state field of an event.

Returns:

#pointer_emulatedBoolean

Returns whether this event is an 'emulated' pointer event.

Emulated pointer events typically originate from a touch events.

Returns:

  • (Boolean)

    true if this event is emulated

#refGdk::Event

Increase the ref count of event.

Returns:

#seatGdk::Seat

Returns the seat that originated the event.

Returns:

#surfaceGdk::Surface

Extracts the surface associated with an event.

Returns:

  • (Gdk::Surface)

    The GdkSurface associated with the event

#timeInteger

Returns the timestamp of event.

Not all events have timestamps. In that case, this function returns %GDK_CURRENT_TIME.

Returns:

  • (Integer)

    timestamp field from event

#triggers_context_menuBoolean

Returns whether a GdkEvent should trigger a context menu, according to platform conventions.

The right mouse button typically triggers context menus.

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.

#unrefnil

Decrease the ref count of event.

If the last reference is dropped, the structure is freed.

Returns:

  • (nil)