HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulesdl2-2.5.5.0Haskell2010

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.

  • 47 types
  • 10 values
  • Packagesdl2-2.5.5.0
  • Exports57
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceEvent.hs

Polling events

6 declarations
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

5 declarations
datadata RegisteredEventData
#

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

Used for registerEvent, below.

Constructors

Instances5Eq, Ord, Show, Generic, Rep
datadata EventPushResult
#

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

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

Watching events

4 declarations

Event data

3 declarations
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
datadata WindowMovedEventData
#

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
newtypenewtype WindowMinimizedEventData
#

The window has been minimized.

Instances5Eq, Ord, Show, Generic, Rep
newtypenewtype WindowMaximizedEventData
#

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
newtypenewtype WindowLostMouseFocusEventData
#

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

datadata KeyboardEventData
#

A keyboard key has been pressed or released.

Constructors

Instances5Eq, Ord, Show, Generic, Rep
datadata TextEditingEventData
#

Keyboard text editing event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep
datadata TextInputEventData
#

Keyboard text input event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Mouse events

datadata MouseMotionEventData
#

A mouse or pointer device was moved.

Constructors

Instances5Eq, Ord, Show, Generic, Rep
datadata MouseButtonEventData
#

A mouse or pointer device button was pressed or released.

Constructors

Instances5Eq, Ord, Show, Generic, Rep
datadata MouseWheelEventData
#

Mouse wheel event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Joystick events

datadata JoyAxisEventData
#

Joystick axis motion event information

Constructors

Instances5Eq, Ord, Show, Generic, Rep
datadata JoyBallEventData
#

Joystick trackball motion event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep
datadata JoyHatEventData
#

Joystick hat position change event information

Constructors

Instances5Eq, Ord, Show, Generic, Rep
datadata JoyButtonEventData
#

Joystick button event information.

Constructors

Instances5Eq, Ord, Show, Generic, Rep
datadata JoyDeviceEventData
#

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

datadata TouchFingerEventData
#

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

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