1.22 <GdkEvent>

Class: <GdkEvent>

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 <GdkEvent> and its related API is rarely needed.

<GdkEvent> structs are immutable.

Procedures

Method: event:-get-angle self event2 ⇒ %return angle
Method: -get-angle self event2 ⇒ %return angle

Returns the relative angle from self 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 #f.

self

Passed: a <GdkEvent>.

first <GdkEvent>

event2

Passed: a <GdkEvent>.

second <GdkEvent>

%return

Returned: a boolean.

#t if the angle could be calculated.

angle

Returned: a real number.

return location for the relative angle between both events

Method: event:-get-center self event2 ⇒ %return x y
Method: -get-center self event2 ⇒ %return x y

Returns the point halfway between the events’ positions.

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

self

Passed: a <GdkEvent>.

first <GdkEvent>

event2

Passed: a <GdkEvent>.

second <GdkEvent>

%return

Returned: a boolean.

#t if the center could be calculated.

x

Returned: a real number.

return location for the X coordinate of the center

y

Returned: a real number.

return location for the Y coordinate of the center

Method: event:-get-distance self event2 ⇒ %return distance
Method: -get-distance self event2 ⇒ %return distance

Returns the distance between the event locations.

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

self

Passed: a <GdkEvent>.

first <GdkEvent>

event2

Passed: a <GdkEvent>.

second <GdkEvent>

%return

Returned: a boolean.

#t if the distance could be calculated.

distance

Returned: a real number.

return location for the distance

Method: event:get-axes self ⇒ %return axes
Method: get-axes self ⇒ %return axes

Extracts all axis values from an event.

To find out which axes are used, use device-tool:get-axes on the device tool returned by event:get-device-tool.

self

Passed: a <GdkEvent>.

a <GdkEvent>

%return

Returned: a boolean.

#t on success, otherwise #f

axes

Returned: a f64vector.

the array of values for all axes

n-axes

Not returned: it is the length of axes.

the length of array

Method: event:get-axis self axis-use ⇒ %return value
Method: get-axis self axis-use ⇒ %return value

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

To find out which axes are used, use device-tool:get-axes on the device tool returned by event:get-device-tool.

self

Passed: a <GdkEvent>.

a <GdkEvent>

axis-use

Passed: a <GdkAxisUse>, or one of its symbols.

the axis use to look for

%return

Returned: a boolean.

#t if the specified axis was found, otherwise #f

value

Returned: a real number.

location to store the value found

Method: event:get-device self ⇒ %return
Method: get-device self ⇒ %return

Returns the device of an event.

self

Passed: a <GdkEvent>.

a <GdkEvent>.

%return

Returned: a <GdkDevice>, or #f.

a <GdkDevice>

Method: event:get-device-tool self ⇒ %return
Method: get-device-tool self ⇒ %return

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 #f.

Note: the <GdkDeviceTool> will be constant during the application lifetime, if settings must be stored persistently across runs, see device-tool:get-serial.

self

Passed: a <GdkEvent>.

a <GdkEvent>

%return

Returned: a <GdkDeviceTool>, or #f.

The current device tool

Method: event:get-display self ⇒ %return
Method: get-display self ⇒ %return

Retrieves the display associated to the self.

self

Passed: a <GdkEvent>.

a <GdkEvent>

%return

Returned: a <GdkDisplay>, or #f.

a <GdkDisplay>

Method: event:get-event-sequence self ⇒ %return
Method: get-event-sequence self ⇒ %return

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.

self

Passed: a <GdkEvent>.

a <GdkEvent>

%return

Returned: a <GdkEventSequence>.

the event sequence that the event belongs to

Method: event:get-event-type self ⇒ %return
Method: get-event-type self ⇒ %return

Retrieves the type of the event.

self

Passed: a <GdkEvent>.

a <GdkEvent>

%return

Returned: a <GdkEventType>.

a <GdkEvent>Type

Method: event:get-history self ⇒ %return
Method: get-history self ⇒ %return

Retrieves the history of the device that self 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 self.

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.

self

Passed: a <GdkEvent>.

a motion or scroll event

%return

Returned: a vector, each a <GdkTimeCoord>, or #f.

an array of time and coordinates

out-n-coords

Not returned: it is the length of %return.

Return location for the length of the returned array

Method: event:get-modifier-state self ⇒ %return
Method: get-modifier-state self ⇒ %return

Returns the modifier state field of an event.

self

Passed: a <GdkEvent>.

a <GdkEvent>

%return

Returned: a <GdkModifierType>.

the modifier state of self

Method: event:get-pointer-emulated? self ⇒ %return
Method: get-pointer-emulated? self ⇒ %return

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

Emulated pointer events typically originate from a touch events.

self

Passed: a <GdkEvent>.

a <GdkEvent>

%return

Returned: a boolean.

#t if this event is emulated

Method: event:get-position self ⇒ %return x y
Method: get-position self ⇒ %return x y

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

This position is in surface coordinates.

self

Passed: a <GdkEvent>.

a <GdkEvent>

%return

Returned: a boolean.

whether the positions were set

x

Returned: a real number.

location to put event surface x coordinate

y

Returned: a real number.

location to put event surface y coordinate

Method: event:get-seat self ⇒ %return
Method: get-seat self ⇒ %return

Returns the seat that originated the event.

self

Passed: a <GdkEvent>.

a <GdkEvent>

%return

Returned: a <GdkSeat>, or #f.

a <GdkSeat>.

Method: event:get-surface self ⇒ %return
Method: get-surface self ⇒ %return

Extracts the surface associated with an event.

self

Passed: a <GdkEvent>.

a <GdkEvent>

%return

Returned: a <GdkSurface>, or #f.

The <GdkSurface> associated with the event

Method: event:get-time self ⇒ %return
Method: get-time self ⇒ %return

Returns the timestamp of self.

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

self

Passed: a <GdkEvent>.

a <GdkEvent>

%return

Returned: an unsigned 32-bit integer.

timestamp field from self

Method: event:ref self ⇒ %return
Method: ref self ⇒ %return

Increase the ref count of self.

self

Passed: a <GdkEvent>.

a <GdkEvent>

%return

Returned: a <GdkEvent>.

self

Method: event:triggers-context-menu? self ⇒ %return
Method: triggers-context-menu? self ⇒ %return

Returns whether a <GdkEvent> 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

event->button == GDK_BUTTON_SECONDARY
self

Passed: a <GdkEvent>.

a <GdkEvent>, currently only button events are meaningful values

%return

Returned: a boolean.

#t if the event should trigger a context menu.

Method: event:unref self
Method: unref self

Decrease the ref count of self.

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

self

Passed: a <GdkEvent>.

a <GdkEvent>