Event

A gdk.Event 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:

1 
2 GdkEvent *event;
3 GdkEventType type;
4 
5 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_BUTTON_PRESS then the x coordinate of the button press can be accessed with:

1 
2 GdkEvent *event;
3 gdouble x;
4 
5 x = ((GdkEventButton*)event)->x;

r:

1 
2 GdkEvent *event;
3 gdouble x;
4 
5 x = event->button.x;
class Event {
bool ownedRef;
}

Constructors

this
this(GdkEvent* gdkEvent, bool ownedRef = false)

Sets our main struct and passes it to the parent class.

this
this(GdkEventType type)

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

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Members

Functions

any
GdkEventAny* any()
button
GdkEventButton* button()
configure
GdkEventConfigure* configure()

Get a specific event.

copy
Event copy()

Copies a gdk.Event, copying or incrementing the reference count of the resources associated with it (e.g. gdk.Window’s and strings).

crossing
GdkEventCrossing* crossing()
dnd
GdkEventDND* dnd()
expose
GdkEventExpose* expose()
focus
GdkEventFocus* focus()

Get a specific event.

free
void free()

Frees a gdk.Event, freeing or decrementing any resources associated with it. Note that this function should only be called with events returned from functions such as Event.peek, Event.get, Event.copy and Event.new.

getAxis
bool getAxis(GdkAxisUse axisUse, out double value)

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

getButton
bool getButton(out uint button)

Extract the button number from an event.

getClickCount
bool getClickCount(out uint clickCount)

Extracts the click count from an event.

getCoords
bool getCoords(out double xWin, out double yWin)

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

getDevice
Device getDevice()

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

getDeviceTool
DeviceTool getDeviceTool()

If the event was generated by a device that supports different tools (eg. a tablet), this function will return a gdk.DeviceTool representing the tool that caused the event. Otherwise, NULL will be returned.

getEventSequence
GdkEventSequence* getEventSequence()

If event if of type GDK_TOUCH_BEGIN, GDK_TOUCH_UPDATE, GDK_TOUCH_END or GDK_TOUCH_CANCEL, returns the gdk.EventSequence to which the event belongs. Otherwise, return NULL.

getEventStruct
GdkEvent* getEventStruct(bool transferOwnership = false)

Get the main Gtk struct

getEventType
GdkEventType getEventType()

Retrieves the type of the event.

getKeycode
bool getKeycode(out ushort keycode)

Extracts the hardware keycode from an event.

getKeyval
bool getKeyval(out uint keyval)

Extracts the keyval from an event.

getPointerEmulated
bool getPointerEmulated()

event.get a gdk.Event Returns whether this event is an 'emulated' pointer event (typically from a touch event), as opposed to a real one.

getRootCoords
bool getRootCoords(out double xRoot, out 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
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(out double deltaX, out double deltaY)

Retrieves the scroll deltas from a gdk.Event

getScrollDirection
bool getScrollDirection(out GdkScrollDirection direction)

Extracts the scroll direction from an event.

getSeat
Seat getSeat()

Returns the gdk.Seat this event was generated for.

getSourceDevice
Device getSourceDevice()

This function returns the hardware (slave) gdk.Device that has triggered the event, falling back to the virtual (master) device (as in 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 gdk.Window updates its geometry or a grab is acquired/released.

getState
bool getState(out GdkModifierType 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.

getStruct
void* getStruct()

the main Gtk struct as a void*

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
Window getWindow()

Extracts the gdk.Window associated with an event.

grabBroken
GdkEventGrabBroken* grabBroken()

Get a specific 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.

key
GdkEventKey* key()
motion
GdkEventMotion* motion()
ownerChange
GdkEventOwnerChange* ownerChange()
property
GdkEventProperty* property()
proximity
GdkEventProximity* proximity()

Get a specific event.

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

scroll
GdkEventScroll* scroll()
selection
GdkEventSelection* selection()

Get a specific event.

setDevice
void setDevice(Device device)

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

setDeviceTool
void setDeviceTool(DeviceTool tool)

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

setScreen
void setScreen(Screen screen)

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

setSourceDevice
void setSourceDevice(Device device)

Sets the slave device for event to device.

setting
GdkEventSetting* setting()

Get a specific event.

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

type
EventType type()

Specifies the type of the event.

visibility
GdkEventVisibility* visibility()
windowState
GdkEventWindowState* windowState()

Get a specific event.

Static functions

get
Event get()

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

getAngle
bool getAngle(Event event1, Event event2, out double angle)

If both events contain X/Y information, this function will return TRUE and return in angle the relative angle from event1 to event2. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.

getCenter
bool getCenter(Event event1, Event event2, out double x, out double y)

If both events contain X/Y information, the center of both coordinates will be returned in x and y.

getDistance
bool getDistance(Event event1, Event event2, out double distance)

If both events have X/Y information, the distance between both coordinates (as in a straight line going from event1 to event2) will be returned.

getShowEvents
bool getShowEvents()

Gets whether event debugging output is enabled.

getType
GType getType()
handlerSet
void handlerSet(GdkEventFunc func, void* data, GDestroyNotify notify)

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

isDoubleClick
bool isDoubleClick(GdkEventButton* eventButton, int buttonNumber = 1)
isTripleClick
bool isTripleClick(GdkEventButton* eventButton, int buttonNumber = 1)
peek
Event peek()

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

pending
bool pending()

Checks if any events are ready to be processed for any display.

requestMotions
void requestMotions(GdkEventMotion* event)

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

setShowEvents
void setShowEvents(bool showEvents)

Sets whether a trace of received events is output. Note that GTK+ must be compiled with debugging (that is, configured using the --enable-debug option) to use this option.

settingGet
bool settingGet(string name, Value value)

Obtains a desktop-wide setting, such as the double-click time, for the default screen. See Screen.getSetting.

Variables

gdkEvent
GdkEvent* gdkEvent;

the main Gtk struct

Meta