haste-compiler-0.5.4.1: Haskell To ECMAScript compiler

Safe HaskellNone
LanguageHaskell98

Haste.Events

Contents

Description

Event handling for Haste.

Synopsis

Core event functionality

class Event evt where Source

Any type that describes an event.

Associated Types

type EventData evt Source

The type of data to pass to handlers for this event.

Methods

eventName :: evt -> JSString Source

The name of this event, as expected by the DOM.

eventData :: evt -> JSAny -> IO (EventData evt) Source

Construct event data from the event identifier and the JS event object.

class MonadIO m => MonadEvent m where Source

Any monad in which we're able to handle events.

Methods

mkHandler :: (a -> m ()) -> m (a -> IO ()) Source

data HandlerInfo Source

Information about an event handler.

unregisterHandler :: MonadIO m => HandlerInfo -> m () Source

Unregister an event handler.

onEvent Source

Arguments

:: (MonadEvent m, IsElem el, Event evt) 
=> el

Element to set handler on.

-> evt

Event to handle.

-> (EventData evt -> m ())

Event handler.

-> m HandlerInfo

Information about the handler.

Set an event handler on a DOM element.

preventDefault :: IO () Source

Prevent the event being handled from resolving normally. Does nothing if called outside an event handler.

Basic events with no arguments

Keyboard-related events

data KeyData Source

Event data for keyboard events.

Constructors

KeyData 

Fields

keyCode :: !Int
 
keyCtrl :: !Bool
 
keyAlt :: !Bool
 
keyShift :: !Bool
 
keyMeta :: !Bool
 

Instances

Eq KeyData Source 
Num KeyData Source

Num instance for KeyData to enable pattern matching against numeric key codes.

Show KeyData Source 

mkKeyData :: Int -> KeyData Source

Build a KeyData object for the given key, without any modifier keys pressed.

Mouse-related events

data MouseData Source

Event data for mouse events.

Constructors

MouseData 

Fields

mouseCoords :: !(Int, Int)

Mouse coordinates.

mouseButton :: !(Maybe MouseButton)

Pressed mouse button, if any.

mouseWheelDeltas :: !(Double, Double, Double)

(x, y, z) mouse wheel delta. Always all zeroes except for Wheel.

Touch-related events

data TouchData Source

Event data for touch events.

Constructors

TouchData 

Fields

touches :: [Touch]

All fingers currently on the screen.

targetTouches :: [Touch]

All fingers on the DOM element receiving the event.

changedTouches :: [Touch]

All fingers involved in the current event. For instance, fingers removed for the TouchEnd event.

data Touch Source

A finger touching the screen.

Constructors

Touch 

Fields

identifier :: !Int

Unique identifier for this touch.

target :: !Elem

Target element of the touch.

pageCoords :: !(Int, Int)

Page coordinates of the touch, including scroll offsets.

clientCoords :: !(Int, Int)

Page coordinates of the touch, excluding scroll offsets.

screenCoords :: !(Int, Int)

Screen coordinates of the touch.

Instances