gi-gdk4-4.0.10: Gdk bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gdk.Objects.Event

Contents

- Exported types
- Methods
  - getAxes
  - getAxis
  - getDevice
  - getDeviceTool
  - getDisplay
  - getEventSequence
  - getEventType
  - getHistory
  - getModifierState
  - getPointerEmulated
  - getPosition
  - getSeat
  - getSurface
  - getTime
  - ref
  - triggersContextMenu
  - unref

Description

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

`GdkEvent` structs are immutable.

Synopsis

- newtype Event = Event (ManagedPtr Event)
- class (BoxedPtr o, TypedObject o, IsDescendantOf Event o) => IsEvent o
- toEvent :: (MonadIO m, IsEvent o) => o -> m Event
- eventGetAxes :: (HasCallStack, MonadIO m, IsEvent a) => a -> m (Bool, [Double])
- eventGetAxis :: (HasCallStack, MonadIO m, IsEvent a) => a -> AxisUse -> m (Bool, Double)
- eventGetDevice :: (HasCallStack, MonadIO m, IsEvent a) => a -> m (Maybe Device)
- eventGetDeviceTool :: (HasCallStack, MonadIO m, IsEvent a) => a -> m (Maybe DeviceTool)
- eventGetDisplay :: (HasCallStack, MonadIO m, IsEvent a) => a -> m (Maybe Display)
- eventGetEventSequence :: (HasCallStack, MonadIO m, IsEvent a) => a -> m EventSequence
- eventGetEventType :: (HasCallStack, MonadIO m, IsEvent a) => a -> m EventType
- eventGetHistory :: (HasCallStack, MonadIO m, IsEvent a) => a -> m (Maybe [TimeCoord])
- eventGetModifierState :: (HasCallStack, MonadIO m, IsEvent a) => a -> m [ModifierType]
- eventGetPointerEmulated :: (HasCallStack, MonadIO m, IsEvent a) => a -> m Bool
- eventGetPosition :: (HasCallStack, MonadIO m, IsEvent a) => a -> m (Bool, Double, Double)
- eventGetSeat :: (HasCallStack, MonadIO m, IsEvent a) => a -> m (Maybe Seat)
- eventGetSurface :: (HasCallStack, MonadIO m, IsEvent a) => a -> m (Maybe Surface)
- eventGetTime :: (HasCallStack, MonadIO m, IsEvent a) => a -> m Word32
- eventRef :: (HasCallStack, MonadIO m, IsEvent a) => a -> m Event
- eventTriggersContextMenu :: (HasCallStack, MonadIO m, IsEvent a) => a -> m Bool
- eventUnref :: (HasCallStack, MonadIO m, IsEvent a) => a -> m ()

# Exported types

newtype Event Source #

Memory-managed wrapper type.

Constructors

Event (ManagedPtr Event) |

#### Instances

Instances details

Eq Event Source # |
Instance details Defined in GI.Gdk.Objects.Event Methods (==) :: Event -> Event -> Bool Source # (/=) :: Event -> Event -> Bool Source #
BoxedPtr Event Source # |
Instance details Defined in GI.Gdk.Objects.Event Methods boxedPtrCopy :: Event -> IO Event Source # boxedPtrFree :: Event -> IO () Source #
ManagedPtrNewtype Event Source # |
Instance details Defined in GI.Gdk.Objects.Event Methods toManagedPtr :: Event -> ManagedPtr Event Source #
TypedObject Event Source # |
Instance details Defined in GI.Gdk.Objects.Event Methods glibType :: IO GType Source #
HasParentTypes Event Source # |
Instance details Defined in GI.Gdk.Objects.Event
type ParentTypes Event Source # |
Instance details Defined in GI.Gdk.Objects.Event type ParentTypes Event = '[] :: [Type]

class (BoxedPtr o, TypedObject o, IsDescendantOf Event o) => IsEvent o Source #

Type class for types which can be safely cast to `Event`, for instance with `toEvent`.

#### Instances

Instances details

(BoxedPtr o, TypedObject o, IsDescendantOf Event o) => IsEvent o Source # |
Instance details Defined in GI.Gdk.Objects.Event

toEvent :: (MonadIO m, IsEvent o) => o -> m Event Source #

Cast to `Event`, for types for which this is known to be safe. For general casts, use `castTo`.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

ref, triggersContextMenu, unref.

#### Getters

getAxes, getAxis, getDevice, getDeviceTool, getDisplay, getEventSequence, getEventType, getHistory, getModifierState, getPointerEmulated, getPosition, getSeat, getSurface, getTime.

#### Setters

None.

## getAxes

eventGetAxes Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`
-> m (Bool, [Double]) | Returns: `True` on success, otherwise `False`

Extracts all axis values from an event.

To find out which axes are used, use `deviceToolGetAxes` on the device tool returned by `eventGetDeviceTool`.

## getAxis

eventGetAxis Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`
-> AxisUse | `axisUse`: the axis use to look for
-> m (Bool, Double) | Returns: `True` if the specified axis was found, otherwise `False`

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

To find out which axes are used, use `deviceToolGetAxes` on the device tool returned by `eventGetDeviceTool`.

## getDevice

eventGetDevice Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`.
-> m (Maybe Device) | Returns: a `GdkDevice`

Returns the device of an event.

## getDeviceTool

eventGetDeviceTool Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`
-> m (Maybe DeviceTool) | Returns: The current device tool

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 `Nothing`.

Note: the `GdkDeviceTool` will be constant during the application lifetime, if settings must be stored persistently across runs, see `deviceToolGetSerial`.

## getDisplay

eventGetDisplay Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`
-> m (Maybe Display) | Returns: a `GdkDisplay`

Retrieves the display associated to the `event`.

## getEventSequence

eventGetEventSequence Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`
-> m EventSequence | Returns: the event sequence that the event belongs to

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

## getEventType

eventGetEventType Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`
-> m EventType | Returns: a `GdkEvent`Type

Retrieves the type of the event.

## getHistory

eventGetHistory Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a motion or scroll event
-> m (Maybe [TimeCoord]) | Returns: an array of time and coordinates

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, or the device has a tool.

## getModifierState

eventGetModifierState Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`
-> m [ModifierType] | Returns: the modifier state of `event`

Returns the modifier state field of an event.

## getPointerEmulated

eventGetPointerEmulated Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`
-> m Bool | Returns: `True` if this event is emulated

Returns whether this event is an 'emulated' pointer event.

Emulated pointer events typically originate from a touch events.

## getPosition

eventGetPosition Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`
-> m (Bool, Double, Double) | Returns: whether the positions were set

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

This position is in surface coordinates.

## getSeat

eventGetSeat Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`
-> m (Maybe Seat) | Returns: a `GdkSeat`.

Returns the seat that originated the event.

## getSurface

eventGetSurface Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`
-> m (Maybe Surface) | Returns: The `GdkSurface` associated with the event

Extracts the surface associated with an event.

## getTime

eventGetTime Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`
-> m Word32 | Returns: timestamp field from `event`

Returns the timestamp of `event`.

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

## ref

eventRef Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`
-> m Event | Returns: `event`

Increase the ref count of `event`.

## triggersContextMenu

eventTriggersContextMenu Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`, currently only button events are meaningful values
-> m Bool | Returns: `True` if the event should trigger a context menu.

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

The right mouse button typically triggers context menus. On macOS, Control+left mouse button also triggers.

This function should always be used instead of simply checking for

### c code

    event->button == GDK_BUTTON_SECONDARY

## unref

eventUnref Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a) |
=> a | `event`: a `GdkEvent`
-> m () |

Decrease the ref count of `event`.

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