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.

GdkEvents are immutable data structures, created by GDK to represent windowing system events.

In GTK applications the events are handled automatically by toplevel widgets and passed on to the event controllers of appropriate widgets, so using GdkEvent and its related API is rarely needed.

  • 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 Class: EventProtocol extension (methods and fields)

  • GetAngle(event2:angle:) Extension method

    Returns the relative angle from event1 to event2.

    The relative angle is the angle between the X axis and the line through both events’ positions. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.

    This assumes that both events have X/Y information. If not, this function returns false.

    Declaration

    Swift

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

    Returns the point halfway between the events’ positions.

    This assumes that both events have X/Y information. If not, this function returns false.

    Declaration

    Swift

    @inlinable
    func GetCenter<EventT>(event2: EventT, x: UnsafeMutablePointer<CDouble>!, y: UnsafeMutablePointer<CDouble>!) -> Bool where EventT : EventProtocol
  • Returns the distance between the event locations.

    This assumes that both events have X/Y information. If not, this function returns false.

    Declaration

    Swift

    @inlinable
    func GetDistance<EventT>(event2: EventT, distance: UnsafeMutablePointer<CDouble>!) -> Bool where EventT : EventProtocol
  • get(axes:nAxes:) Extension method

    Extracts all axis values from an event.

    Declaration

    Swift

    @inlinable
    func get(axes: UnsafeMutablePointer<UnsafeMutablePointer<CDouble>?>!, nAxes: UnsafeMutablePointer<guint>!) -> Bool
  • 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<CDouble>!) -> Bool
  • getDevice() Extension method

    Returns the device of an event.

    Declaration

    Swift

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

    Returns a GdkDeviceTool representing the tool that caused the event.

    If the was not generated by a device that supports different tools (such as a tablet), this function will return nil.

    Note: the GdkDeviceTool will be constant during the application lifetime, if settings must be stored persistently across runs, see [methodGdk.DeviceTool.get_serial].

    Declaration

    Swift

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

    Retrieves the display associated to the event.

    Declaration

    Swift

    @inlinable
    func getDisplay() -> DisplayRef!
  • getEventSequence() Extension method

    Retuns the event sequence to which the event belongs.

    Related touch events are connected in a sequence. Other events typically don’t have event sequence information.

    Declaration

    Swift

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

    Retrieves the type of the event.

    Declaration

    Swift

    @inlinable
    func getEventType() -> GdkEventType
  • getHistory(outNCoords:) Extension method

    Retrieves the history of the device that event is for, as a list of time and coordinates.

    The history includes positions that are not delivered as separate events to the application because they occurred in the same frame as event.

    Note that only motion and scroll events record history, and motion events do it only if one of the mouse buttons is down.

    Declaration

    Swift

    @inlinable
    func getHistory(outNCoords: UnsafeMutablePointer<guint>!) -> UnsafeMutablePointer<GdkTimeCoord>!
  • getModifierState() Extension method

    Returns the modifier state field of an event.

    Declaration

    Swift

    @inlinable
    func getModifierState() -> ModifierType
  • getPointerEmulated() Extension method

    Returns whether this event is an ‘emulated’ pointer event.

    Emulated pointer events typically originate from a touch events.

    Declaration

    Swift

    @inlinable
    func getPointerEmulated() -> Bool
  • getPosition(x:y:) Extension method

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

    Declaration

    Swift

    @inlinable
    func getPosition(x: UnsafeMutablePointer<CDouble>!, y: UnsafeMutablePointer<CDouble>!) -> Bool
  • getSeat() Extension method

    Returns the seat that originated the event.

    Declaration

    Swift

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

    Extracts the surface associated with an event.

    Declaration

    Swift

    @inlinable
    func getSurface() -> SurfaceRef!
  • getTime() Extension method

    Returns the timestamp of event.

    Not all events have timestamps. In that case, this function returns GDK_CURRENT_TIME.

    Declaration

    Swift

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

    Increase the ref count of event.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func ref() -> EventRef!
  • triggersContextMenu() Extension method

    Returns whether a GdkEvent should trigger a context menu, according to platform conventions.

    The right mouse button typically triggers context menus.

    This function should always be used instead of simply checking for event->button == GDK_BUTTON_SECONDARY.

    Declaration

    Swift

    @inlinable
    func triggersContextMenu() -> Bool
  • unref() Extension method

    Decrease the ref count of event.

    If the last reference is dropped, the structure is freed.

    Declaration

    Swift

    @inlinable
    func unref()
  • Returns the relative angle from event1 to event2.

    The relative angle is the angle between the X axis and the line through both events’ positions. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.

    This assumes that both events have X/Y information. If not, this function returns false.

    Declaration

    Swift

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

    Returns the point halfway between the events’ positions.

    This assumes that both events have X/Y information. If not, this function returns false.

    Declaration

    Swift

    @inlinable
    func eventsGetCenter<EventT>(event2: EventT, x: UnsafeMutablePointer<CDouble>!, y: UnsafeMutablePointer<CDouble>!) -> Bool where EventT : EventProtocol
  • Returns the distance between the event locations.

    This assumes that both events have X/Y information. If not, this function returns false.

    Declaration

    Swift

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

    Returns the device of an event.

    Declaration

    Swift

    @inlinable
    var device: DeviceRef! { get }
  • deviceTool Extension method

    Returns a GdkDeviceTool representing the tool that caused the event.

    If the was not generated by a device that supports different tools (such as a tablet), this function will return nil.

    Note: the GdkDeviceTool will be constant during the application lifetime, if settings must be stored persistently across runs, see [methodGdk.DeviceTool.get_serial].

    Declaration

    Swift

    @inlinable
    var deviceTool: DeviceToolRef! { get }
  • display Extension method

    Retrieves the display associated to the event.

    Declaration

    Swift

    @inlinable
    var display: DisplayRef! { get }
  • eventSequence Extension method

    Retuns the event sequence to which the event belongs.

    Related touch events are connected in a sequence. Other events typically don’t have event sequence information.

    Declaration

    Swift

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

    Retrieves the type of the event.

    Declaration

    Swift

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

    Returns the modifier state field of an event.

    Declaration

    Swift

    @inlinable
    var modifierState: ModifierType { get }
  • pointerEmulated Extension method

    Returns whether this event is an ‘emulated’ pointer event.

    Emulated pointer events typically originate from a touch events.

    Declaration

    Swift

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

    Returns the seat that originated the event.

    Declaration

    Swift

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

    Extracts the surface associated with an event.

    Declaration

    Swift

    @inlinable
    var surface: SurfaceRef! { get }
  • time Extension method

    Returns the timestamp of event.

    Not all events have timestamps. In that case, this function returns GDK_CURRENT_TIME.

    Declaration

    Swift

    @inlinable
    var time: guint32 { get }