jsaddle-dom-0.9.3.2: DOM library that uses jsaddle to support both GHCJS and GHC

Safe HaskellNone
LanguageHaskell2010

JSDOM.EventM

Contents

Description

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

Documentation

TODO: small tutorial w/ example function

type EventM t e = ReaderT e DOM Source #

IO with the current Event in scope (read with event).

data EventName 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 element click $ 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

event :: EventM t e e Source #

target :: (IsEvent e, IsGObject t) => EventM t e (Maybe t) Source #

UIEvent helpers

MouseEvent helpers