haste-compiler-0.5.5.0: Haskell To ECMAScript compiler

Safe HaskellNone
LanguageHaskell98

Haste.Events

Contents

Description

Event handling for Haste.

Synopsis

Core event functionality

class Event evt where

Any type that describes an event.

Associated Types

type EventData evt

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

Methods

eventName :: evt -> JSString

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

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

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

class MonadIO m => MonadEvent m where

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

Methods

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

data HandlerInfo

Information about an event handler.

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

Unregister an event handler.

onEvent

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 ()

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

Basic events with no arguments

data BasicEvent

Constructors

Load 
Unload 
Change 
Focus 
Blur 
Submit 
Scroll 

Instances

Keyboard-related events

data KeyEvent

Constructors

KeyPress 
KeyUp 
KeyDown 

data KeyData

Event data for keyboard events.

Constructors

KeyData 

Fields

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

Instances

Eq KeyData 
Num KeyData

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

Show KeyData 

mkKeyData :: Int -> KeyData

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

Mouse-related events

data MouseData

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

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

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