Safe Haskell | None |
---|---|
Language | Haskell2010 |
EventM
provides a convenient monadic interface for handling DOM events.
The DOM Event interface is exposed, as well as functions for accessing UIEvents and MouseEvents.
Synopsis
- type EventM t e = ReaderT e DOM
- newtype SaferEventListener t e = SaferEventListener Function
- data EventName t e
- newListener :: IsEvent e => EventM t e () -> DOM (SaferEventListener t e)
- newListenerSync :: IsEvent e => EventM t e () -> DOM (SaferEventListener t e)
- newListenerAsync :: IsEvent e => EventM t e () -> DOM (SaferEventListener t e)
- addListener :: (IsEventTarget t, IsEvent e) => t -> EventName t e -> SaferEventListener t e -> Bool -> DOM ()
- removeListener :: (IsEventTarget t, IsEvent e) => t -> EventName t e -> SaferEventListener t e -> Bool -> DOM ()
- releaseListener :: (IsEventTarget t, IsEvent e) => SaferEventListener t e -> DOM ()
- on :: (IsEventTarget t, IsEvent e) => t -> EventName t e -> EventM t e () -> DOM (DOM ())
- onSync :: (IsEventTarget t, IsEvent e) => t -> EventName t e -> EventM t e () -> DOM (DOM ())
- onAsync :: (IsEventTarget t, IsEvent e) => t -> EventName t e -> EventM t e () -> JSM (JSM ())
- onTheseSync :: (IsEventTarget t, IsEvent e) => [(t, EventName t e)] -> EventM t e () -> DOM (DOM ())
- onTheseAsync :: (IsEventTarget t, IsEvent e) => [(t, EventName t e)] -> EventM t e () -> DOM (DOM ())
- event :: EventM t e e
- eventTarget :: IsEvent e => EventM t e (Maybe EventTarget)
- target :: (IsEvent e, IsGObject t) => EventM t e (Maybe t)
- eventCurrentTarget :: IsEvent e => EventM t e (Maybe EventTarget)
- eventPhase :: IsEvent e => EventM t e Word
- bubbles :: IsEvent e => EventM t e Bool
- cancelable :: IsEvent e => EventM t e Bool
- timeStamp :: IsEvent e => EventM t e Word
- stopPropagation :: IsEvent e => EventM t e ()
- preventDefault :: IsEvent e => EventM t e ()
- defaultPrevented :: IsEvent e => EventM t e Bool
- stopImmediatePropagation :: IsEvent e => EventM t e ()
- srcElement :: IsEvent e => EventM t e EventTarget
- getCancelBubble :: IsEvent e => EventM t e Bool
- cancelBubble :: IsEvent e => Bool -> EventM t e ()
- getReturnValue :: IsEvent e => EventM t e Bool
- returnValue :: IsEvent e => Bool -> EventM t e ()
- uiView :: IsUIEvent e => EventM t e Window
- uiDetail :: IsUIEvent e => EventM t e Int
- uiKeyCode :: EventM t KeyboardEvent Word
- uiCharCode :: EventM t KeyboardEvent Word
- uiLayerX :: IsUIEvent e => EventM t e Int
- uiLayerY :: IsUIEvent e => EventM t e Int
- uiLayerXY :: IsUIEvent e => EventM t e (Int, Int)
- uiPageX :: IsUIEvent e => EventM t e Int
- uiPageY :: IsUIEvent e => EventM t e Int
- uiPageXY :: IsUIEvent e => EventM t e (Int, Int)
- uiWhich :: IsUIEvent e => EventM t e Int
- mouseScreenX :: IsMouseEvent e => EventM t e Int
- mouseScreenY :: IsMouseEvent e => EventM t e Int
- mouseScreenXY :: IsMouseEvent e => EventM t e (Int, Int)
- mouseClientX :: IsMouseEvent e => EventM t e Int
- mouseClientY :: IsMouseEvent e => EventM t e Int
- mouseClientXY :: IsMouseEvent e => EventM t e (Int, Int)
- mouseMovementX :: IsMouseEvent e => EventM t e Int
- mouseMovementY :: IsMouseEvent e => EventM t e Int
- mouseMovementXY :: IsMouseEvent e => EventM t e (Int, Int)
- mouseCtrlKey :: IsMouseEvent e => EventM t e Bool
- mouseShiftKey :: IsMouseEvent e => EventM t e Bool
- mouseAltKey :: IsMouseEvent e => EventM t e Bool
- mouseMetaKey :: IsMouseEvent e => EventM t e Bool
- mouseButton :: IsMouseEvent e => EventM t e Word
- mouseRelatedTarget :: IsMouseEvent e => EventM t e (Maybe EventTarget)
- mouseOffsetX :: IsMouseEvent e => EventM t e Int
- mouseOffsetY :: IsMouseEvent e => EventM t e Int
- mouseOffsetXY :: IsMouseEvent e => EventM t e (Int, Int)
- mouseX :: IsMouseEvent e => EventM t e Int
- mouseY :: IsMouseEvent e => EventM t e Int
- mouseXY :: IsMouseEvent e => EventM t e (Int, Int)
- mouseFromElement :: IsMouseEvent e => EventM t e (Maybe Node)
- mouseToElement :: IsMouseEvent e => EventM t e (Maybe Node)
Documentation
TODO: small tutorial w/ example function
newtype SaferEventListener t e Source #
Instances
ToJSVal (SaferEventListener t e) Source # | |
Defined in JSDOM.EventTargetClosures toJSVal :: SaferEventListener t e -> JSM JSVal # toJSValListOf :: [SaferEventListener t e] -> JSM JSVal # |
newListener :: IsEvent e => EventM t e () -> DOM (SaferEventListener t e) Source #
See eventListenerNew
.
newListenerSync :: IsEvent e => EventM t e () -> DOM (SaferEventListener t e) Source #
See eventListenerNewSync
.
newListenerAsync :: IsEvent e => EventM t e () -> DOM (SaferEventListener t e) Source #
addListener :: (IsEventTarget t, IsEvent e) => t -> EventName t e -> SaferEventListener t e -> Bool -> DOM () Source #
Add an EventListener to an EventTarget.
removeListener :: (IsEventTarget t, IsEvent e) => t -> EventName t e -> SaferEventListener t e -> Bool -> DOM () Source #
Remove an EventListener from an EventTarget.
releaseListener :: (IsEventTarget t, IsEvent e) => SaferEventListener t e -> DOM () Source #
Release the listener (deallocates callbacks).
on :: (IsEventTarget t, IsEvent e) => t -> EventName t e -> EventM t e () -> DOM (DOM ()) Source #
Shortcut for create, add and release:
releaseAction <- on elementclick
$ do w <-currentWindowUnchecked
alert
w "I was clicked!" -- remove click handler again releaseAction
onSync :: (IsEventTarget t, IsEvent e) => t -> EventName t e -> EventM t e () -> DOM (DOM ()) Source #
Like on
but always uses newListenerSync
onAsync :: (IsEventTarget t, IsEvent e) => t -> EventName t e -> EventM t e () -> JSM (JSM ()) Source #
Like on
but always uses newListenerAsync
onTheseSync :: (IsEventTarget t, IsEvent e) => [(t, EventName t e)] -> EventM t e () -> DOM (DOM ()) Source #
onSync
for multiple targets & events.
The returned IO
action removes them all at once.
onTheseAsync :: (IsEventTarget t, IsEvent e) => [(t, EventName t e)] -> EventM t e () -> DOM (DOM ()) Source #
onAsync
for multiple targets & events.
The returned IO
action removes them all at once.
Event interface
eventTarget :: IsEvent e => EventM t e (Maybe EventTarget) Source #
eventCurrentTarget :: IsEvent e => EventM t e (Maybe EventTarget) Source #
stopPropagation :: IsEvent e => EventM t e () Source #
preventDefault :: IsEvent e => EventM t e () Source #
stopImmediatePropagation :: IsEvent e => EventM t e () Source #
srcElement :: IsEvent e => EventM t e EventTarget Source #
UIEvent helpers
uiCharCode :: EventM t KeyboardEvent Word Source #
MouseEvent helpers
mouseScreenX :: IsMouseEvent e => EventM t e Int Source #
mouseScreenY :: IsMouseEvent e => EventM t e Int Source #
mouseScreenXY :: IsMouseEvent e => EventM t e (Int, Int) Source #
mouseClientX :: IsMouseEvent e => EventM t e Int Source #
mouseClientY :: IsMouseEvent e => EventM t e Int Source #
mouseClientXY :: IsMouseEvent e => EventM t e (Int, Int) Source #
mouseMovementX :: IsMouseEvent e => EventM t e Int Source #
mouseMovementY :: IsMouseEvent e => EventM t e Int Source #
mouseMovementXY :: IsMouseEvent e => EventM t e (Int, Int) Source #
mouseCtrlKey :: IsMouseEvent e => EventM t e Bool Source #
mouseShiftKey :: IsMouseEvent e => EventM t e Bool Source #
mouseAltKey :: IsMouseEvent e => EventM t e Bool Source #
mouseMetaKey :: IsMouseEvent e => EventM t e Bool Source #
mouseButton :: IsMouseEvent e => EventM t e Word Source #
mouseRelatedTarget :: IsMouseEvent e => EventM t e (Maybe EventTarget) Source #
mouseOffsetX :: IsMouseEvent e => EventM t e Int Source #
mouseOffsetY :: IsMouseEvent e => EventM t e Int Source #
mouseOffsetXY :: IsMouseEvent e => EventM t e (Int, Int) Source #
mouseFromElement :: IsMouseEvent e => EventM t e (Maybe Node) Source #
mouseToElement :: IsMouseEvent e => EventM t e (Maybe Node) Source #