EventProtocol
public protocol EventProtocol
The EventProtocol protocol exposes the methods and properties of an underlying GdkEvent instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see Event.
Alternatively, use EventRef as a lighweight, unowned reference if you already have an instance you just want to use.
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: (C Language Example):
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_BUTTON_PRESS
then the x coordinate of the button press can be accessed with:
(C Language Example):
GdkEvent *event;
gdouble x;
x = ((GdkEventButton*)event)->x;
or: (C Language Example):
GdkEvent *event;
gdouble x;
x = event->button.x;
-
Untyped pointer to the underlying
GdkEventinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
event_ptrDefault implementationTyped pointer to the underlying
GdkEventinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GdkEventinstance.Declaration
Swift
var event_ptr: UnsafeMutablePointer<GdkEvent>! { get } -
Required Initialiser for types conforming to
EventProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
GetAngle(event2:Extension methodangle: ) If both events contain X/Y information, this function will return
trueand return inanglethe relative angle fromevent1toevent2. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.Declaration
Swift
@inlinable func GetAngle<EventT>(event2: EventT, angle: UnsafeMutablePointer<gdouble>!) -> Bool where EventT : EventProtocol -
GetCenter(event2:Extension methodx: y: ) If both events contain X/Y information, the center of both coordinates will be returned in
xandy.Declaration
Swift
@inlinable func GetCenter<EventT>(event2: EventT, x: UnsafeMutablePointer<gdouble>!, y: UnsafeMutablePointer<gdouble>!) -> Bool where EventT : EventProtocol -
GetDistance(event2:Extension methoddistance: ) If both events have X/Y information, the distance between both coordinates (as in a straight line going from
event1toevent2) will be returned.Declaration
Swift
@inlinable func GetDistance<EventT>(event2: EventT, distance: UnsafeMutablePointer<gdouble>!) -> Bool where EventT : EventProtocol -
copy()Extension methodCopies a
GdkEvent, copying or incrementing the reference count of the resources associated with it (e.g.GdkWindow’s and strings).Declaration
Swift
@inlinable func copy() -> EventRef! -
free()Extension methodFrees a
GdkEvent, freeing or decrementing any resources associated with it. Note that this function should only be called with events returned from functions such asgdk_event_peek(),gdk_event_get(),gdk_event_copy()andgdk_event_new().Declaration
Swift
@inlinable func free() -
getAxis(axisUse:Extension methodvalue: ) Extract the axis value for a particular axis use from an event structure.
Declaration
Swift
@inlinable func getAxis(axisUse: GdkAxisUse, value: UnsafeMutablePointer<gdouble>!) -> Bool -
get(button:Extension method) Extract the button number from an event.
Declaration
Swift
@inlinable func get(button: UnsafeMutablePointer<guint>!) -> Bool -
get(clickCount:Extension method) Extracts the click count from an event.
Declaration
Swift
@inlinable func get(clickCount: UnsafeMutablePointer<guint>!) -> Bool -
getCoords(xWin:Extension methodyWin: ) Extract the event window relative x/y coordinates from an event.
Declaration
Swift
@inlinable func getCoords(xWin: UnsafeMutablePointer<gdouble>! = nil, yWin: UnsafeMutablePointer<gdouble>! = nil) -> Bool -
getDevice()Extension methodIf the event contains a “device” field, this function will return it, else it will return
nil.Declaration
Swift
@inlinable func getDevice() -> DeviceRef! -
getDeviceTool()Extension methodIf the event was generated by a device that supports different tools (eg. a tablet), this function will return a
GdkDeviceToolrepresenting the tool that caused the event. Otherwise,nilwill be returned.Note: the
GdkDeviceTool<!– –>s will be constant during the application lifetime, if settings must be stored persistently across runs, seegdk_device_tool_get_serial()Declaration
Swift
@inlinable func getDeviceTool() -> DeviceToolRef! -
getEventSequence()Extension methodIf
eventif of typeGDK_TOUCH_BEGIN,GDK_TOUCH_UPDATE,GDK_TOUCH_ENDorGDK_TOUCH_CANCEL, returns theGdkEventSequenceto which the event belongs. Otherwise, returnnil.Declaration
Swift
@inlinable func getEventSequence() -> EventSequenceRef! -
getEventType()Extension methodRetrieves the type of the event.
Declaration
Swift
@inlinable func getEventType() -> GdkEventType -
get(keycode:Extension method) Extracts the hardware keycode from an event.
Also see
gdk_event_get_scancode().Declaration
Swift
@inlinable func get(keycode: UnsafeMutablePointer<guint16>!) -> Bool -
get(keyval:Extension method) Extracts the keyval from an event.
Declaration
Swift
@inlinable func get(keyval: UnsafeMutablePointer<guint>!) -> Bool -
getPointerEmulated()Extension methodevent:aGdkEventReturns whether this event is an ‘emulated’ pointer event (typically from a touch event), as opposed to a real one.Declaration
Swift
@inlinable func getPointerEmulated() -> Bool -
getRootCoords(xRoot:Extension methodyRoot: ) Extract the root window relative x/y coordinates from an event.
Declaration
Swift
@inlinable func getRootCoords(xRoot: UnsafeMutablePointer<gdouble>! = nil, yRoot: UnsafeMutablePointer<gdouble>! = nil) -> Bool -
getScancode()Extension methodGets the keyboard low-level scancode of a key event.
This is usually hardware_keycode. On Windows this is the high word of WM_KEY{DOWN,UP} lParam which contains the scancode and some extended flags.
Declaration
Swift
@inlinable func getScancode() -> Int -
getScreen()Extension methodReturns 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 whichevent->motion.x_rootandevent->motion.y_rootare relative.Declaration
Swift
@inlinable func getScreen() -> ScreenRef! -
getScrollDeltas(deltaX:Extension methoddeltaY: ) Retrieves the scroll deltas from a
GdkEventSee also:
gdk_event_get_scroll_direction()Declaration
Swift
@inlinable func getScrollDeltas(deltaX: UnsafeMutablePointer<gdouble>!, deltaY: UnsafeMutablePointer<gdouble>!) -> Bool -
getScroll(direction:Extension method) Extracts the scroll direction from an event.
If
eventis not of typeGDK_SCROLL, the contents ofdirectionare undefined.If you wish to handle both discrete and smooth scrolling, you should check the return value of this function, or of
gdk_event_get_scroll_deltas(); for instance:(C Language Example):
GdkScrollDirection direction; double vscroll_factor = 0.0; double x_scroll, y_scroll; if (gdk_event_get_scroll_direction (event, &direction)) { // Handle discrete scrolling with a known constant delta; const double delta = 12.0; switch (direction) { case GDK_SCROLL_UP: vscroll_factor = -delta; break; case GDK_SCROLL_DOWN: vscroll_factor = delta; break; default: // no scrolling break; } } else if (gdk_event_get_scroll_deltas (event, &x_scroll, &y_scroll)) { // Handle smooth scrolling directly vscroll_factor = y_scroll; }Declaration
Swift
@inlinable func getScroll(direction: UnsafeMutablePointer<GdkScrollDirection>!) -> Bool -
getSeat()Extension methodReturns the
GdkSeatthis event was generated for.Declaration
Swift
@inlinable func getSeat() -> SeatRef! -
getSourceDevice()Extension methodThis function returns the hardware (slave)
GdkDevicethat has triggered the event, falling back to the virtual (master) device (as ingdk_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 aGdkWindowupdates its geometry or a grab is acquired/released.If the event does not contain a device field, this function will return
nil.Declaration
Swift
@inlinable func getSourceDevice() -> DeviceRef! -
get(state:Extension method) If the event contains a “state” field, puts that field in
state. Otherwise stores an empty state (0). Returnstrueif there was a state field in the event.eventmay benil, in which case it’s treated as if the event had no state field.Declaration
Swift
@inlinable func get(state: UnsafeMutablePointer<GdkModifierType>!) -> Bool -
getTime()Extension methodReturns the time stamp from
event, if there is one; otherwise returnsGDK_CURRENT_TIME. Ifeventisnil, returnsGDK_CURRENT_TIME.Declaration
Swift
@inlinable func getTime() -> guint32 -
getWindow()Extension methodExtracts the
GdkWindowassociated with an event.Declaration
Swift
@inlinable func getWindow() -> WindowRef! -
put()Extension methodAppends 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
nil. Seegdk_display_put_event().Declaration
Swift
@inlinable func put() -
set(device:Extension method) Sets the device for
eventtodevice. The event must have been allocated by GTK+, for instance, bygdk_event_copy().Declaration
Swift
@inlinable func set<DeviceT>(device: DeviceT) where DeviceT : DeviceProtocol -
setDevice(tool:Extension method) Sets the device tool for this event, should be rarely used.
Declaration
Swift
@inlinable func setDevice(tool: DeviceToolRef? = nil) -
setDevice(tool:Extension method) Sets the device tool for this event, should be rarely used.
Declaration
Swift
@inlinable func setDevice<DeviceToolT>(tool: DeviceToolT?) where DeviceToolT : DeviceToolProtocol -
set(screen:Extension method) Sets the screen for
eventtoscreen. The event must have been allocated by GTK+, for instance, bygdk_event_copy().Declaration
Swift
@inlinable func set<ScreenT>(screen: ScreenT) where ScreenT : ScreenProtocol -
setSource(device:Extension method) Sets the slave device for
eventtodevice.The event must have been allocated by GTK+, for instance by
gdk_event_copy().Declaration
Swift
@inlinable func setSource<DeviceT>(device: DeviceT) where DeviceT : DeviceProtocol -
triggersContextMenu()Extension methodThis function returns whether a
GdkEventButtonshould trigger a context menu, according to platform conventions. The right mouse button always triggers context menus. Additionally, ifgdk_keymap_get_modifier_mask()returns a non-0 mask forGDK_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.Declaration
Swift
@inlinable func triggersContextMenu() -> Bool -
eventsGetAngle(event2:Extension methodangle: ) If both events contain X/Y information, this function will return
trueand return inanglethe relative angle fromevent1toevent2. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.Declaration
Swift
@inlinable func eventsGetAngle<EventT>(event2: EventT, angle: UnsafeMutablePointer<gdouble>!) -> Bool where EventT : EventProtocol -
eventsGetCenter(event2:Extension methodx: y: ) If both events contain X/Y information, the center of both coordinates will be returned in
xandy.Declaration
Swift
@inlinable func eventsGetCenter<EventT>(event2: EventT, x: UnsafeMutablePointer<gdouble>!, y: UnsafeMutablePointer<gdouble>!) -> Bool where EventT : EventProtocol -
eventsGetDistance(event2:Extension methoddistance: ) If both events have X/Y information, the distance between both coordinates (as in a straight line going from
event1toevent2) will be returned.Declaration
Swift
@inlinable func eventsGetDistance<EventT>(event2: EventT, distance: UnsafeMutablePointer<gdouble>!) -> Bool where EventT : EventProtocol -
deviceExtension methodIf the event contains a “device” field, this function will return it, else it will return
nil.Declaration
Swift
@inlinable var device: DeviceRef! { get nonmutating set } -
deviceToolExtension methodIf the event was generated by a device that supports different tools (eg. a tablet), this function will return a
GdkDeviceToolrepresenting the tool that caused the event. Otherwise,nilwill be returned.Note: the
GdkDeviceTool<!– –>s will be constant during the application lifetime, if settings must be stored persistently across runs, seegdk_device_tool_get_serial()Declaration
Swift
@inlinable var deviceTool: DeviceToolRef! { get nonmutating set } -
eventSequenceExtension methodIf
eventif of typeGDK_TOUCH_BEGIN,GDK_TOUCH_UPDATE,GDK_TOUCH_ENDorGDK_TOUCH_CANCEL, returns theGdkEventSequenceto which the event belongs. Otherwise, returnnil.Declaration
Swift
@inlinable var eventSequence: EventSequenceRef! { get } -
eventTypeExtension methodRetrieves the type of the event.
Declaration
Swift
@inlinable var eventType: GdkEventType { get } -
isScrollStopEventExtension methodCheck 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.
Stop scroll events always have a a delta of 0/0.
Declaration
Swift
@inlinable var isScrollStopEvent: Bool { get } -
pointerEmulatedExtension methodevent:aGdkEventReturns whether this event is an ‘emulated’ pointer event (typically from a touch event), as opposed to a real one.Declaration
Swift
@inlinable var pointerEmulated: Bool { get } -
scancodeExtension methodGets the keyboard low-level scancode of a key event.
This is usually hardware_keycode. On Windows this is the high word of WM_KEY{DOWN,UP} lParam which contains the scancode and some extended flags.
Declaration
Swift
@inlinable var scancode: Int { get } -
screenExtension methodReturns 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 whichevent->motion.x_rootandevent->motion.y_rootare relative.Declaration
Swift
@inlinable var screen: ScreenRef! { get nonmutating set } -
seatExtension methodReturns the
GdkSeatthis event was generated for.Declaration
Swift
@inlinable var seat: SeatRef! { get } -
sourceDeviceExtension methodThis function returns the hardware (slave)
GdkDevicethat has triggered the event, falling back to the virtual (master) device (as ingdk_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 aGdkWindowupdates its geometry or a grab is acquired/released.If the event does not contain a device field, this function will return
nil.Declaration
Swift
@inlinable var sourceDevice: DeviceRef! { get nonmutating set } -
timeExtension methodReturns the time stamp from
event, if there is one; otherwise returnsGDK_CURRENT_TIME. Ifeventisnil, returnsGDK_CURRENT_TIME.Declaration
Swift
@inlinable var time: guint32 { get } -
windowExtension methodExtracts the
GdkWindowassociated with an event.Declaration
Swift
@inlinable var window: WindowRef! { get } -
typeExtension methodthe
GdkEventTypeDeclaration
Swift
@inlinable var type: GdkEventType { get set } -
anyExtension methoda
GdkEventAnyDeclaration
Swift
@inlinable var any: GdkEventAny { get set } -
exposeExtension methoda
GdkEventExposeDeclaration
Swift
@inlinable var expose: GdkEventExpose { get set } -
visibilityExtension methoda
GdkEventVisibilityDeclaration
Swift
@inlinable var visibility: GdkEventVisibility { get set } -
motionExtension methoda
GdkEventMotionDeclaration
Swift
@inlinable var motion: GdkEventMotion { get set } -
buttonExtension methoda
GdkEventButtonDeclaration
Swift
@inlinable var button: GdkEventButton { get set } -
touchExtension methoda
GdkEventTouchDeclaration
Swift
@inlinable var touch: GdkEventTouch { get set } -
scrollExtension methoda
GdkEventScrollDeclaration
Swift
@inlinable var scroll: GdkEventScroll { get set } -
keyExtension methoda
GdkEventKeyDeclaration
Swift
@inlinable var key: GdkEventKey { get set } -
crossingExtension methoda
GdkEventCrossingDeclaration
Swift
@inlinable var crossing: GdkEventCrossing { get set } -
focusChangeExtension methoda
GdkEventFocusDeclaration
Swift
@inlinable var focusChange: GdkEventFocus { get set } -
configureExtension methoda
GdkEventConfigureDeclaration
Swift
@inlinable var configure: GdkEventConfigure { get set } -
propertyExtension methoda
GdkEventPropertyDeclaration
Swift
@inlinable var property: GdkEventProperty { get set } -
selectionExtension methoda
GdkEventSelectionDeclaration
Swift
@inlinable var selection: GdkEventSelection { get set } -
ownerChangeExtension methoda
GdkEventOwnerChangeDeclaration
Swift
@inlinable var ownerChange: GdkEventOwnerChange { get set } -
proximityExtension methoda
GdkEventProximityDeclaration
Swift
@inlinable var proximity: GdkEventProximity { get set } -
dndExtension methoda
GdkEventDNDDeclaration
Swift
@inlinable var dnd: GdkEventDND { get set } -
windowStateExtension methoda
GdkEventWindowStateDeclaration
Swift
@inlinable var windowState: GdkEventWindowState { get set } -
settingExtension methoda
GdkEventSettingDeclaration
Swift
@inlinable var setting: GdkEventSetting { get set } -
grabBrokenExtension methoda
GdkEventGrabBrokenDeclaration
Swift
@inlinable var grabBroken: GdkEventGrabBroken { get set } -
touchpadSwipeExtension methoda
GdkEventTouchpadSwipeDeclaration
Swift
@inlinable var touchpadSwipe: GdkEventTouchpadSwipe { get set } -
touchpadPinchExtension methoda
GdkEventTouchpadPinchDeclaration
Swift
@inlinable var touchpadPinch: GdkEventTouchpadPinch { get set } -
padButtonExtension methoda
GdkEventPadButtonDeclaration
Swift
@inlinable var padButton: GdkEventPadButton { get set } -
padAxisExtension methoda
GdkEventPadAxisDeclaration
Swift
@inlinable var padAxis: GdkEventPadAxis { get set } -
padGroupModeExtension methoda
GdkEventPadGroupModeDeclaration
Swift
@inlinable var padGroupMode: GdkEventPadGroupMode { get set }
View on GitHub
Install in Dash
EventProtocol Protocol Reference