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;
  • ptr

    Untyped pointer to the underlying GdkEvent instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • event_ptr Default implementation

    Typed 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)

Event Union: EventProtocol extension (methods and fields)

  • GetAngle(event2:angle:) Extension method

    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.

    Declaration

    Swift

    @inlinable
    func GetAngle<EventT>(event2: EventT, angle: UnsafeMutablePointer<gdouble>!) -> Bool where EventT : EventProtocol
  • GetCenter(event2:x:y:) Extension method

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

    Declaration

    Swift

    @inlinable
    func GetCenter<EventT>(event2: EventT, x: UnsafeMutablePointer<gdouble>!, y: UnsafeMutablePointer<gdouble>!) -> Bool where EventT : EventProtocol
  • 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.

    Declaration

    Swift

    @inlinable
    func GetDistance<EventT>(event2: EventT, distance: UnsafeMutablePointer<gdouble>!) -> Bool where EventT : EventProtocol
  • copy() Extension method

    Copies 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 method

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

    Declaration

    Swift

    @inlinable
    func free()
  • getAxis(axisUse:value:) Extension method

    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:yWin:) Extension method

    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 method

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

    Declaration

    Swift

    @inlinable
    func getDevice() -> DeviceRef!
  • getDeviceTool() Extension method

    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, nil will be returned.

    Note: the GdkDeviceTool<!– –>s will be constant during the application lifetime, if settings must be stored persistently across runs, see gdk_device_tool_get_serial()

    Declaration

    Swift

    @inlinable
    func getDeviceTool() -> DeviceToolRef!
  • getEventSequence() Extension method

    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 nil.

    Declaration

    Swift

    @inlinable
    func getEventSequence() -> EventSequenceRef!
  • getEventType() Extension method

    Retrieves 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 method

    event: a GdkEvent 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:yRoot:) Extension method

    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 method

    Gets 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 method

    Returns the screen for the event. The screen is typically the screen for event-&gt;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-&gt;motion.x_root and event-&gt;motion.y_root are relative.

    Declaration

    Swift

    @inlinable
    func getScreen() -> ScreenRef!
  • 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 type GDK_SCROLL, the contents of direction 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 method

    Returns the GdkSeat this event was generated for.

    Declaration

    Swift

    @inlinable
    func getSeat() -> SeatRef!
  • getSourceDevice() Extension method

    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 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). Returns true if there was a state field in the event. event may be nil, 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 method

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

    Declaration

    Swift

    @inlinable
    func getTime() -> guint32
  • getWindow() Extension method

    Extracts the GdkWindow associated with an event.

    Declaration

    Swift

    @inlinable
    func getWindow() -> WindowRef!
  • put() Extension method

    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 nil. See gdk_display_put_event().

    Declaration

    Swift

    @inlinable
    func put()
  • set(device:) Extension method

    Sets the device for event to device. The event must have been allocated by GTK+, for instance, by gdk_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 to screen. The event must have been allocated by GTK+, for instance, by gdk_event_copy().

    Declaration

    Swift

    @inlinable
    func set<ScreenT>(screen: ScreenT) where ScreenT : ScreenProtocol
  • setSource(device:) Extension method

    Sets the slave device for event to device.

    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 method

    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.

    Declaration

    Swift

    @inlinable
    func triggersContextMenu() -> Bool
  • 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.

    Declaration

    Swift

    @inlinable
    func eventsGetAngle<EventT>(event2: EventT, angle: UnsafeMutablePointer<gdouble>!) -> Bool where EventT : EventProtocol
  • eventsGetCenter(event2:x:y:) Extension method

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

    Declaration

    Swift

    @inlinable
    func eventsGetCenter<EventT>(event2: EventT, x: UnsafeMutablePointer<gdouble>!, y: UnsafeMutablePointer<gdouble>!) -> Bool where EventT : EventProtocol
  • 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.

    Declaration

    Swift

    @inlinable
    func eventsGetDistance<EventT>(event2: EventT, distance: UnsafeMutablePointer<gdouble>!) -> Bool where EventT : EventProtocol
  • device Extension method

    If 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 method

    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, nil will be returned.

    Note: the GdkDeviceTool<!– –>s will be constant during the application lifetime, if settings must be stored persistently across runs, see gdk_device_tool_get_serial()

    Declaration

    Swift

    @inlinable
    var deviceTool: DeviceToolRef! { get nonmutating set }
  • eventSequence Extension method

    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 nil.

    Declaration

    Swift

    @inlinable
    var eventSequence: EventSequenceRef! { get }
  • eventType Extension method

    Retrieves the type of the event.

    Declaration

    Swift

    @inlinable
    var eventType: GdkEventType { get }
  • isScrollStopEvent Extension method

    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.

    Stop scroll events always have a a delta of 0/0.

    Declaration

    Swift

    @inlinable
    var isScrollStopEvent: Bool { get }
  • pointerEmulated Extension method

    event: a GdkEvent 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 method

    Gets 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 method

    Returns the screen for the event. The screen is typically the screen for event-&gt;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-&gt;motion.x_root and event-&gt;motion.y_root are relative.

    Declaration

    Swift

    @inlinable
    var screen: ScreenRef! { get nonmutating set }
  • seat Extension method

    Returns the GdkSeat this event was generated for.

    Declaration

    Swift

    @inlinable
    var seat: SeatRef! { get }
  • sourceDevice Extension method

    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 nil.

    Declaration

    Swift

    @inlinable
    var sourceDevice: DeviceRef! { get nonmutating set }
  • time Extension method

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

    Declaration

    Swift

    @inlinable
    var time: guint32 { get }
  • window Extension method

    Extracts the GdkWindow associated with an event.

    Declaration

    Swift

    @inlinable
    var window: WindowRef! { get }
  • type Extension method

    the GdkEventType

    Declaration

    Swift

    @inlinable
    var type: GdkEventType { get set }
  • any Extension method

    a GdkEventAny

    Declaration

    Swift

    @inlinable
    var any: GdkEventAny { get set }
  • expose Extension method

    a GdkEventExpose

    Declaration

    Swift

    @inlinable
    var expose: GdkEventExpose { get set }
  • visibility Extension method

    a GdkEventVisibility

    Declaration

    Swift

    @inlinable
    var visibility: GdkEventVisibility { get set }
  • motion Extension method

    a GdkEventMotion

    Declaration

    Swift

    @inlinable
    var motion: GdkEventMotion { get set }
  • button Extension method

    a GdkEventButton

    Declaration

    Swift

    @inlinable
    var button: GdkEventButton { get set }
  • touch Extension method

    a GdkEventTouch

    Declaration

    Swift

    @inlinable
    var touch: GdkEventTouch { get set }
  • scroll Extension method

    a GdkEventScroll

    Declaration

    Swift

    @inlinable
    var scroll: GdkEventScroll { get set }
  • key Extension method

    a GdkEventKey

    Declaration

    Swift

    @inlinable
    var key: GdkEventKey { get set }
  • crossing Extension method

    a GdkEventCrossing

    Declaration

    Swift

    @inlinable
    var crossing: GdkEventCrossing { get set }
  • focusChange Extension method

    a GdkEventFocus

    Declaration

    Swift

    @inlinable
    var focusChange: GdkEventFocus { get set }
  • configure Extension method

    a GdkEventConfigure

    Declaration

    Swift

    @inlinable
    var configure: GdkEventConfigure { get set }
  • property Extension method

    a GdkEventProperty

    Declaration

    Swift

    @inlinable
    var property: GdkEventProperty { get set }
  • selection Extension method

    a GdkEventSelection

    Declaration

    Swift

    @inlinable
    var selection: GdkEventSelection { get set }
  • ownerChange Extension method

    a GdkEventOwnerChange

    Declaration

    Swift

    @inlinable
    var ownerChange: GdkEventOwnerChange { get set }
  • proximity Extension method

    a GdkEventProximity

    Declaration

    Swift

    @inlinable
    var proximity: GdkEventProximity { get set }
  • dnd Extension method

    a GdkEventDND

    Declaration

    Swift

    @inlinable
    var dnd: GdkEventDND { get set }
  • windowState Extension method

    a GdkEventWindowState

    Declaration

    Swift

    @inlinable
    var windowState: GdkEventWindowState { get set }
  • setting Extension method

    a GdkEventSetting

    Declaration

    Swift

    @inlinable
    var setting: GdkEventSetting { get set }
  • grabBroken Extension method

    a GdkEventGrabBroken

    Declaration

    Swift

    @inlinable
    var grabBroken: GdkEventGrabBroken { get set }
  • touchpadSwipe Extension method

    a GdkEventTouchpadSwipe

    Declaration

    Swift

    @inlinable
    var touchpadSwipe: GdkEventTouchpadSwipe { get set }
  • touchpadPinch Extension method

    a GdkEventTouchpadPinch

    Declaration

    Swift

    @inlinable
    var touchpadPinch: GdkEventTouchpadPinch { get set }
  • padButton Extension method

    a GdkEventPadButton

    Declaration

    Swift

    @inlinable
    var padButton: GdkEventPadButton { get set }
  • padAxis Extension method

    a GdkEventPadAxis

    Declaration

    Swift

    @inlinable
    var padAxis: GdkEventPadAxis { get set }
  • padGroupMode Extension method

    a GdkEventPadGroupMode

    Declaration

    Swift

    @inlinable
    var padGroupMode: GdkEventPadGroupMode { get set }