HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Modulesdl2-2.5.6.1Haskell2010

SDL.Event

SDL.Event exports an interface for working with the SDL event model. Event handling allows your application to receive input from the user. Internally, SDL stores all the events waiting to be handled in an event queue. Using functions like pollEvent and waitEvent you can observe and handle waiting input events.

The event queue itself is composed of a series of Event values, one for each waiting event. Event values are read from the queue with the pollEvent function and it is then up to the application to process the information stored with them.

Contents
  1. Polling events
  2. Registering user events
  3. Watching events
  4. Event data
  5. Window events
  6. Keyboard events
  7. Mouse events
  8. Joystick events
  9. Controller events
  10. Audio events
  11. User events
  12. Touch events
  13. Gesture events
  14. Drag and drop events
  15. Unknown events
  16. Auxiliary event data
Synopsis
  • Packagesdl2-2.5.6.1
  • Exports58
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceEvent.hs

Polling events

valuepollEvent :: MonadIO m => m (Maybe Event)

Poll for currently pending events. You can only call this function in the OS thread that set the video mode.

valuepollEvents :: MonadIO m => m [Event]

Clear the event queue by polling for all pending events.

Like pollEvent this function should only be called in the OS thread which set the video mode.

valuemapEvents :: MonadIO m => (Event -> m ()) -> m ()

Run a monadic computation, accumulating over all known Events.

This can be useful when used with a state monad, allowing you to fold all events together.

valuepumpEvents :: MonadIO m => m ()

Pump the event loop, gathering events from the input devices.

This function updates the event queue and internal input device state.

This should only be run in the OS thread that initialized the video subsystem, and for extra safety, you should consider only doing those things on the main thread in any case.

pumpEvents gathers all the pending input information from devices and places it in the event queue. Without calls to pumpEvents no events would ever be placed on the queue. Often the need for calls to pumpEvents is hidden from the user since pollEvent and waitEvent implicitly call pumpEvents. However, if you are not polling or waiting for events (e.g. you are filtering them), then you must call pumpEvents to force an event queue update.

See SDL_PumpEvents for C documentation.

Registering user events

A record used to convert between SDL Events and user-defined data structures.

Used for registerEvent, below.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Possible results of an attempted push of an event to the queue.

Instances7Eq, Data, Ord, Read, Show, Generic, …

Watching events

Event data

datadata Event

A single SDL event. This event occurred at eventTimestamp and carries data under eventPayload.

Constructors

Instances5Eq, Ord, Show, Generic, Rep
datadata EventPayload

An enumeration of all possible SDL event types. This data type pairs up event types with their payload, where possible.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Window events

newtypenewtype WindowShownEventData

A window has been shown.

Instances5Eq, Ord, Show, Generic, Rep
newtypenewtype WindowHiddenEventData

A window has been hidden.

Instances5Eq, Ord, Show, Generic, Rep
newtypenewtype WindowExposedEventData

A part of a window has been exposed - where exposure means to become visible (for example, an overlapping window no longer overlaps with the window).

Instances5Eq, Ord, Show, Generic, Rep

A Window has been moved.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Window has been resized. This is event is always preceded by WindowSizeChangedEvent.

Instances5Eq, Ord, Show, Generic, Rep

The window size has changed, either as a result of an API call or through the system or user changing the window size; this event is followed by WindowResizedEvent if the size was changed by an external event, i.e. the user or the window manager.

Instances5Eq, Ord, Show, Generic, Rep

The window has been minimized.

Instances5Eq, Ord, Show, Generic, Rep

The window has been maximized.

Instances5Eq, Ord, Show, Generic, Rep
newtypenewtype WindowRestoredEventData

The window has been restored to normal size and position.

Instances5Eq, Ord, Show, Generic, Rep

The window has gained mouse focus.

Instances5Eq, Ord, Show, Generic, Rep

The window has lost mouse focus.

Instances5Eq, Ord, Show, Generic, Rep

The window has gained keyboard focus.

Instances5Eq, Ord, Show, Generic, Rep

The window has lost keyboard focus.

Instances5Eq, Ord, Show, Generic, Rep
newtypenewtype WindowClosedEventData

The window manager requests that the window be closed.

Instances5Eq, Ord, Show, Generic, Rep
newtypenewtype SysWMEventData

A video driver dependent system event

Instances5Eq, Ord, Show, Generic, Rep

Keyboard events

A keyboard key has been pressed or released.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Keyboard text editing event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Keyboard text input event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Mouse events

A mouse or pointer device was moved.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

A mouse or pointer device button was pressed or released.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Mouse wheel event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Joystick events

Joystick axis motion event information

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Joystick trackball motion event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Joystick hat position change event information

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Joystick button event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Joystick device event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Controller events

Game controller axis motion event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Game controller button event information

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Controller device event information

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Audio events

datadata AudioDeviceEventData
#

Constructors

Instances5Eq, Ord, Show, Generic, Rep

User events

datadata UserEventData

Event data for application-defined events.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Touch events

Finger touch event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Finger motion event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Gesture events

Multiple finger gesture event information

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Complex gesture event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Drag and drop events

newtypenewtype DropEventData

An event used to request a file open by the system

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Unknown events

newtypenewtype UnknownEventData

SDL reported an unknown event type.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Auxiliary event data

datadata InputMotion
#
Instances9Bounded, Enum, Eq, Data, Ord, Read, …
datadata MouseButton
#
Instances9Eq, Data, Ord, Read, Show, Generic, …