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
GdkEvent
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
event_ptr
Default implementationTyped pointer to the underlying
GdkEvent
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GdkEvent
instance.Declaration
Swift
var event_ptr: UnsafeMutablePointer<GdkEvent>! { get }
-
Required Initialiser for types conforming to
EventProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
GetAngle(event2:
Extension methodangle: ) If both events contain X/Y information, this function will return
true
and return inangle
the relative angle fromevent1
toevent2
. 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
x
andy
.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
event1
toevent2
) 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
GdkDeviceTool
representing the tool that caused the event. Otherwise,nil
will 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
event
if of typeGDK_TOUCH_BEGIN
,GDK_TOUCH_UPDATE
,GDK_TOUCH_END
orGDK_TOUCH_CANCEL
, returns theGdkEventSequence
to 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:
aGdkEvent
Returns 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_root
andevent->motion.y_root
are relative.Declaration
Swift
@inlinable func getScreen() -> ScreenRef!
-
getScrollDeltas(deltaX:
Extension methoddeltaY: ) Retrieves the scroll deltas from a
GdkEvent
See 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
event
is not of typeGDK_SCROLL
, the contents ofdirection
are 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
GdkSeat
this event was generated for.Declaration
Swift
@inlinable func getSeat() -> SeatRef!
-
getSourceDevice()
Extension methodThis function returns the hardware (slave)
GdkDevice
that 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 aGdkWindow
updates 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). Returnstrue
if there was a state field in the event.event
may 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
. Ifevent
isnil
, returnsGDK_CURRENT_TIME
.Declaration
Swift
@inlinable func getTime() -> guint32
-
getWindow()
Extension methodExtracts the
GdkWindow
associated 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
event
todevice
. 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
event
toscreen
. 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
event
todevice
.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
GdkEventButton
should 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
true
and return inangle
the relative angle fromevent1
toevent2
. 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
x
andy
.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
event1
toevent2
) will be returned.Declaration
Swift
@inlinable func eventsGetDistance<EventT>(event2: EventT, distance: UnsafeMutablePointer<gdouble>!) -> Bool where EventT : EventProtocol
-
device
Extension 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 }
-
deviceTool
Extension methodIf 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,nil
will 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 }
-
eventSequence
Extension methodIf
event
if of typeGDK_TOUCH_BEGIN
,GDK_TOUCH_UPDATE
,GDK_TOUCH_END
orGDK_TOUCH_CANCEL
, returns theGdkEventSequence
to which the event belongs. Otherwise, returnnil
.Declaration
Swift
@inlinable var eventSequence: EventSequenceRef! { get }
-
eventType
Extension methodRetrieves the type of the event.
Declaration
Swift
@inlinable var eventType: GdkEventType { get }
-
isScrollStopEvent
Extension 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 }
-
pointerEmulated
Extension methodevent:
aGdkEvent
Returns 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 }
-
scancode
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 var scancode: Int { get }
-
screen
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_root
andevent->motion.y_root
are relative.Declaration
Swift
@inlinable var screen: ScreenRef! { get nonmutating set }
-
seat
Extension methodReturns the
GdkSeat
this event was generated for.Declaration
Swift
@inlinable var seat: SeatRef! { get }
-
sourceDevice
Extension methodThis function returns the hardware (slave)
GdkDevice
that 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 aGdkWindow
updates 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 }
-
time
Extension methodReturns the time stamp from
event
, if there is one; otherwise returnsGDK_CURRENT_TIME
. Ifevent
isnil
, returnsGDK_CURRENT_TIME
.Declaration
Swift
@inlinable var time: guint32 { get }
-
window
Extension methodExtracts the
GdkWindow
associated with an event.Declaration
Swift
@inlinable var window: WindowRef! { get }
-
type
Extension methodthe
GdkEventType
Declaration
Swift
@inlinable var type: GdkEventType { get set }
-
any
Extension methoda
GdkEventAny
Declaration
Swift
@inlinable var any: GdkEventAny { get set }
-
expose
Extension methoda
GdkEventExpose
Declaration
Swift
@inlinable var expose: GdkEventExpose { get set }
-
visibility
Extension methoda
GdkEventVisibility
Declaration
Swift
@inlinable var visibility: GdkEventVisibility { get set }
-
motion
Extension methoda
GdkEventMotion
Declaration
Swift
@inlinable var motion: GdkEventMotion { get set }
-
button
Extension methoda
GdkEventButton
Declaration
Swift
@inlinable var button: GdkEventButton { get set }
-
touch
Extension methoda
GdkEventTouch
Declaration
Swift
@inlinable var touch: GdkEventTouch { get set }
-
scroll
Extension methoda
GdkEventScroll
Declaration
Swift
@inlinable var scroll: GdkEventScroll { get set }
-
key
Extension methoda
GdkEventKey
Declaration
Swift
@inlinable var key: GdkEventKey { get set }
-
crossing
Extension methoda
GdkEventCrossing
Declaration
Swift
@inlinable var crossing: GdkEventCrossing { get set }
-
focusChange
Extension methoda
GdkEventFocus
Declaration
Swift
@inlinable var focusChange: GdkEventFocus { get set }
-
configure
Extension methoda
GdkEventConfigure
Declaration
Swift
@inlinable var configure: GdkEventConfigure { get set }
-
property
Extension methoda
GdkEventProperty
Declaration
Swift
@inlinable var property: GdkEventProperty { get set }
-
selection
Extension methoda
GdkEventSelection
Declaration
Swift
@inlinable var selection: GdkEventSelection { get set }
-
ownerChange
Extension methoda
GdkEventOwnerChange
Declaration
Swift
@inlinable var ownerChange: GdkEventOwnerChange { get set }
-
proximity
Extension methoda
GdkEventProximity
Declaration
Swift
@inlinable var proximity: GdkEventProximity { get set }
-
dnd
Extension methoda
GdkEventDND
Declaration
Swift
@inlinable var dnd: GdkEventDND { get set }
-
windowState
Extension methoda
GdkEventWindowState
Declaration
Swift
@inlinable var windowState: GdkEventWindowState { get set }
-
setting
Extension methoda
GdkEventSetting
Declaration
Swift
@inlinable var setting: GdkEventSetting { get set }
-
grabBroken
Extension methoda
GdkEventGrabBroken
Declaration
Swift
@inlinable var grabBroken: GdkEventGrabBroken { get set }
-
touchpadSwipe
Extension methoda
GdkEventTouchpadSwipe
Declaration
Swift
@inlinable var touchpadSwipe: GdkEventTouchpadSwipe { get set }
-
touchpadPinch
Extension methoda
GdkEventTouchpadPinch
Declaration
Swift
@inlinable var touchpadPinch: GdkEventTouchpadPinch { get set }
-
padButton
Extension methoda
GdkEventPadButton
Declaration
Swift
@inlinable var padButton: GdkEventPadButton { get set }
-
padAxis
Extension methoda
GdkEventPadAxis
Declaration
Swift
@inlinable var padAxis: GdkEventPadAxis { get set }
-
padGroupMode
Extension methoda
GdkEventPadGroupMode
Declaration
Swift
@inlinable var padGroupMode: GdkEventPadGroupMode { get set }