Event

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.types.EventType.ButtonPress 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;
class Event : Boxed {}

Constructors

this
this(void* ptr, Flag!"Take" take)
this
this(gdk.types.EventType type)

Creates a new event of the given type. All fields are set to 0.

Members

Functions

_cPtr
void* _cPtr(Flag!"Dup" dup)
copy
gdk.event.Event copy()

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

getAxis
bool getAxis(gdk.types.AxisUse axisUse, double value)

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

getButton
bool getButton(uint button)

Extract the button number from an event.

getClickCount
bool getClickCount(uint clickCount)

Extracts the click count from an event.

getCoords
bool getCoords(double xWin, double yWin)

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

getDevice
gdk.device.Device getDevice()

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

getDeviceTool
gdk.device_tool.DeviceTool getDeviceTool()

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.

getEventSequence
gdk.event_sequence.EventSequence getEventSequence()

If event if of type gdk.types.EventType.TouchBegin, gdk.types.EventType.TouchUpdate, gdk.types.EventType.TouchEnd or gdk.types.EventType.TouchCancel, returns the #GdkEventSequence to which the event belongs. Otherwise, return null.

getEventType
gdk.types.EventType getEventType()

Retrieves the type of the event.

getKeycode
bool getKeycode(ushort keycode)

Extracts the hardware keycode from an event.

getKeyval
bool getKeyval(uint keyval)

Extracts the keyval from an event.

getPointerEmulated
bool getPointerEmulated()

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

getRootCoords
bool getRootCoords(double xRoot, double yRoot)

Extract the root window relative x/y coordinates from an event.

getScancode
int getScancode()

Gets the keyboard low-level scancode of a key event.

getScreen
gdk.screen.Screen getScreen()

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.

getScrollDeltas
bool getScrollDeltas(double deltaX, double deltaY)

Retrieves the scroll deltas from a #GdkEvent

getScrollDirection
bool getScrollDirection(gdk.types.ScrollDirection direction)

Extracts the scroll direction from an event.

getSeat
gdk.seat.Seat getSeat()

Returns the #GdkSeat this event was generated for.

getSourceDevice
gdk.device.Device getSourceDevice()

This function returns the hardware (slave) #GdkDevice that has triggered the event, falling back to the virtual (master) device (as in gdk.event.Event.getDevice) 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.

getState
bool getState(gdk.types.ModifierType state)

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.

getTime
uint getTime()

Returns the time stamp from event, if there is one; otherwise returns #GDK_CURRENT_TIME. If event is null, returns #GDK_CURRENT_TIME.

getWindow
gdk.window.Window getWindow()

Extracts the #GdkWindow associated with an event.

isScrollStopEvent
bool isScrollStopEvent()

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.

put
void put()

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.Display.putEvent.

self
Event self()

Returns this, for use in with statements.

setDevice
void setDevice(gdk.device.Device device)

Sets the device for event to device. The event must have been allocated by GTK+, for instance, by gdk.event.Event.copy.

setDeviceTool
void setDeviceTool(gdk.device_tool.DeviceTool tool)

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

setScreen
void setScreen(gdk.screen.Screen screen)

Sets the screen for event to screen. The event must have been allocated by GTK+, for instance, by gdk.event.Event.copy.

setSourceDevice
void setSourceDevice(gdk.device.Device device)

Sets the slave device for event to device.

triggersContextMenu
bool triggersContextMenu()

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.Keymap.getModifierMask returns a non-0 mask for gdk.types.ModifierIntent.ContextMenu, then the left mouse button will also trigger a context menu if this modifier is pressed.

Properties

_gType
GType _gType [@property getter]
any
gdk.event_any.EventAny any [@property getter]

Get any field.

button
gdk.event_button.EventButton button [@property getter]

Get button field.

configure
gdk.event_configure.EventConfigure configure [@property getter]

Get configure field.

crossing
gdk.event_crossing.EventCrossing crossing [@property getter]

Get crossing field.

dnd
gdk.event_dnd.EventDND dnd [@property getter]

Get dnd field.

expose
gdk.event_expose.EventExpose expose [@property getter]

Get expose field.

focusChange
gdk.event_focus.EventFocus focusChange [@property getter]

Get focusChange field.

grabBroken
gdk.event_grab_broken.EventGrabBroken grabBroken [@property getter]

Get grabBroken field.

key
gdk.event_key.EventKey key [@property getter]

Get key field.

motion
gdk.event_motion.EventMotion motion [@property getter]

Get motion field.

ownerChange
gdk.event_owner_change.EventOwnerChange ownerChange [@property getter]

Get ownerChange field.

padAxis
gdk.event_pad_axis.EventPadAxis padAxis [@property getter]

Get padAxis field.

padButton
gdk.event_pad_button.EventPadButton padButton [@property getter]

Get padButton field.

padGroupMode
gdk.event_pad_group_mode.EventPadGroupMode padGroupMode [@property getter]

Get padGroupMode field.

property
gdk.event_property.EventProperty property [@property getter]

Get property field.

proximity
gdk.event_proximity.EventProximity proximity [@property getter]

Get proximity field.

scroll
gdk.event_scroll.EventScroll scroll [@property getter]

Get scroll field.

selection
gdk.event_selection.EventSelection selection [@property getter]

Get selection field.

setting
gdk.event_setting.EventSetting setting [@property getter]

Get setting field.

touch
gdk.event_touch.EventTouch touch [@property getter]

Get touch field.

touchpadPinch
gdk.event_touchpad_pinch.EventTouchpadPinch touchpadPinch [@property getter]

Get touchpadPinch field.

touchpadSwipe
gdk.event_touchpad_swipe.EventTouchpadSwipe touchpadSwipe [@property getter]

Get touchpadSwipe field.

type
gdk.types.EventType type [@property getter]

Get type field.

type
gdk.types.EventType type [@property setter]

Set type field.

visibility
gdk.event_visibility.EventVisibility visibility [@property getter]

Get visibility field.

windowState
gdk.event_window_state.EventWindowState windowState [@property getter]

Get windowState field.

Static functions

_getGType
GType _getGType()
get
gdk.event.Event get()

Checks all open displays for a #GdkEvent to process,to be processed on, fetching events from the windowing system if necessary. See gdk.display.Display.getEvent.

handlerSet
void handlerSet(gdk.types.EventFunc func)

Sets the function to call to handle all events from GDK.

peek
gdk.event.Event peek()

If there is an event waiting in the event queue of some open display, returns a copy of it. See gdk.display.Display.peekEvent.

requestMotions
void requestMotions(gdk.event_motion.EventMotion event)

Request more motion notifies if event is a motion notify hint event.

Inherited Members

From Boxed

_cInstancePtr
void* _cInstancePtr;

Pointer to the C boxed value

_getGType
GType _getGType()

Get the GType of this boxed type.

_gType
GType _gType [@property getter]

Boxed GType property.

self
Boxed self()

Convenience method to return this cast to a type. For use in D with statements.

boxCopy
void* boxCopy()

Make a copy of the wrapped C boxed data.

boxedCopy
void* boxedCopy(void* cBoxed)

Copy a C boxed value using g_boxed_copy.

boxedFree
void boxedFree(void* cBoxed)

Free a C boxed value using g_boxed_free.