class Gdk::Event

Overview

Represents 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 Gdk::Event and its related API is rarely needed.

Gdk::Event structs are immutable.

Direct Known Subclasses

Defined in:

lib/gi-crystal/src/auto/gdk-4.0/event.cr
lib/gtk4/src/bindings/gdk/event.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def _get_angle(event2 : Gdk::Event, angle : Float64) : Bool #

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.


def _get_center(event2 : Gdk::Event, x : Float64, y : Float64) : Bool #

Returns the point halfway between the events' positions.

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


def _get_distance(event2 : Gdk::Event, distance : Float64) : Bool #

Returns the distance between the event locations.

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


def axes(axes : Enumerable(Float64)) : Bool #

Extracts all axis values from an event.

To find out which axes are used, use Gdk::DeviceTool#axes on the device tool returned by Gdk::Event#device_tool.


def axes(*axes : Float64) #

def axis(axis_use : Gdk::AxisUse, value : Float64) : Bool #

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

To find out which axes are used, use Gdk::DeviceTool#axes on the device tool returned by Gdk::Event#device_tool.


def device : Gdk::Device | Nil #

Returns the device of an event.


def device_tool : Gdk::DeviceTool | Nil #

Returns a Gdk::DeviceTool 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 Gdk::DeviceTool will be constant during the application lifetime, if settings must be stored persistently across runs, see Gdk::DeviceTool#serial.


def display : Gdk::Display | Nil #

Retrieves the display associated to the event.


def event_sequence : Gdk::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.


def event_type : Gdk::EventType #

Retrieves the type of the event.


def finalize #

Called by the garbage collector. Decreases the reference count of object. (i.e. its memory is freed).


def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def history : Enumerable(Gdk::TimeCoord) | Nil #

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.


def modifier_state : Gdk::ModifierType #

Returns the modifier state field of an event.


def pointer_emulated : Bool #

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

Emulated pointer events typically originate from a touch events.


def position(x : Float64, y : Float64) : Bool #

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

This position is in surface coordinates.


def seat : Gdk::Seat | Nil #

Returns the seat that originated the event.


def surface : Gdk::Surface | Nil #

Extracts the surface associated with an event.


def time : UInt32 #

Returns the timestamp of event.

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


def to_unsafe : Pointer(Void) #

Returns a pointer to the C object.


def triggers_context_menu : Bool #

Returns whether a Gdk::Event should trigger a context menu, according to platform conventions.

The right mouse button typically triggers context menus. On macOS, Control+left mouse button also triggers.

This function should always be used instead of simply checking for

WARNING ⚠️ The following code is in c ⚠️

event->button == GDK_BUTTON_SECONDARY