class Gdk::Event

Overview

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

Direct Known Subclasses

Defined in:

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

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(pointer : Pointer(Void), transfer : GICrystal::Transfer) #

[View source]

Class Method Detail

def self.g_type : UInt64 #

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


[View source]

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.


[View source]
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.


[View source]
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.


[View source]
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.


[View source]
def axes(*axes : Float64) #

[View source]
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.


[View source]
def device : Gdk::Device | Nil #

Returns the device of an event.


[View source]
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.


[View source]
def display : Gdk::Display | Nil #

Retrieves the display associated to the event.


[View source]
def event_sequence : Gdk::EventSequence #

Retuns 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.


[View source]
def event_type : Gdk::EventType #

Retrieves the type of the event.


[View source]
def finalize #

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


[View source]
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.


[View source]
def modifier_state : Gdk::ModifierType #

Returns the modifier state field of an event.


[View source]
def pointer_emulated : Bool #

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

Emulated pointer events typically originate from a touch events.


[View source]
def position(x : Float64, y : Float64) : Bool #

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


[View source]
def seat : Gdk::Seat | Nil #

Returns the seat that originated the event.


[View source]
def surface : Gdk::Surface | Nil #

Extracts the surface associated with an event.


[View source]
def time : UInt32 #

Returns the timestamp of event.

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


[View source]
def to_unsafe : Pointer(Void) #

Returns a pointer to the C object.


[View source]
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.

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


[View source]