Event

This section describes functions dealing with events from the window system.

In GTK+ applications the events are handled automatically in gtk_main_do_event() and passed on to the appropriate widgets, so these functions are rarely needed. Though some of the fields in the Event Structures are useful.

class Event {}

Constructors

this
this(GdkEvent* gdkEvent)

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. Since 2.2

Members

Functions

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

Get a specific event.

copy
Event copy()

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

crossing
GdkEventCrossing* crossing()
dnd
GdkEventDND* dnd()

Get a specific event.

eventsGetAngle
int eventsGetAngle(Event event2, 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.

eventsGetCenter
int eventsGetCenter(Event event2, double x, double y)

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

eventsGetDistance
int eventsGetDistance(Event event2, 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.

expose
GdkEventExpose* expose()
focus
GdkEventFocus* focus()

Get a specific event.

free
void free()

Frees a GdkEvent, freeing or decrementing any resources associated with it. Note that this function should only be called with events returned from functions such as gdk_event_peek(), gdk_event_get(), gdk_event_copy() and gdk_event_new().

getAxis
int getAxis(GdkAxisUse axisUse, double value)

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

getButton
int getButton(uint button)

Extract the button number from an event.

getClickCount
int getClickCount(uint clickCount)

Extracts the click count from an event.

getCoords
int getCoords(double xWin, 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.

getEventSequence
GdkEventSequence* getEventSequence()

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

getEventStruct
GdkEvent* getEventStruct()

Get the main Gtk struct

getEventType
GdkEventType getEventType()

Retrieves the type of the event.

getKeycode
int getKeycode(ushort keycode)

Extracts the hardware keycode from an event.

getKeyval
int getKeyval(uint keyval)

Extracts the keyval from an event.

getRootCoords
int getRootCoords(double xRoot, double yRoot)

Extract the root window relative x/y coordinates from an 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. Since 2.2

getScrollDeltas
int getScrollDeltas(double deltaX, double deltaY)

Retrieves the scroll deltas from a GdkEvent

getScrollDirection
int getScrollDirection(GdkScrollDirection direction)

Extracts the scroll direction from an event.

getSourceDevice
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_get_device()) 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. If the event does not contain a device field, this function will return NULL.

getState
int getState(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 GDK_CURRENT_TIME. If event is NULL, returns GDK_CURRENT_TIME.

getWindow
Window getWindow()

Extracts the GdkWindow associated with an event.

grabBroken
GdkEventGrabBroken* grabBroken()
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 gdk_display_put_event().

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 gdk_event_copy().

setScreen
void setScreen(Screen screen)

Sets the screen for event to screen. The event must have been allocated by GTK+, for instance, by gdk_event_copy(). Since 2.2

setSourceDevice
void setSourceDevice(Device device)

Sets the slave device for event to device. The event must have been allocated by GTK+, for instance by gdk_event_copy().

setting
GdkEventSetting* setting()

Get a specific event.

triggersContextMenu
int 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_get_modifier_mask() 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. This function should always be used instead of simply checking for event->button == GDK_BUTTON_SECONDARY.

type
EventType type()

Specifies the type of the event.

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

Get a specific event.

Static functions

eventsPending
int eventsPending()

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

get
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_get_event().

getShowEvents
int getShowEvents()

Gets whether event debugging output is enabled.

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

Sets the function to call to handle all events from GDK. Note that GTK+ uses this to install its own event handler, so it is usually not useful for GTK+ applications. (Although an application can call this function then call gtk_main_do_event() to pass events to GTK+.)

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

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

requestMotions
void requestMotions(GdkEventMotion* event)

Request more motion notifies if event is a motion notify hint event. This function should be used instead of gdk_window_get_pointer() to request further motion notifies, because it also works for extension events where motion notifies are provided for devices other than the core pointer. Coordinate extraction, processing and requesting more Since 2.12

setShowEvents
void setShowEvents(int 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
int settingGet(string name, Value value)

Obtains a desktop-wide setting, such as the double-click time, for the default screen. See gdk_screen_get_setting().

Variables

gdkEvent
GdkEvent* gdkEvent;

the main Gtk struct

Meta