miso-1.8.2.0: A tasty Haskell front-end framework
Copyright(C) 2016-2018 David M. Johnson
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <djohnson.m@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Miso.Html.Event

Description

 
Synopsis

Custom event handlers

on :: MisoString -> Decoder r -> (r -> action) -> Attribute action Source #

Convenience wrapper for onWithOptions defaultOptions.

let clickHandler = on "click" emptyDecoder $ \() -> Action
in button_ [ clickHandler, class_ "add" ] [ text_ "+" ]

onWithOptions :: Options -> MisoString -> Decoder r -> (r -> action) -> Attribute action Source #

onWithOptions opts eventName decoder toAction is an attribute that will set the event handler of the associated DOM node to a function that decodes its argument using decoder, converts it to an action using toAction and then feeds that action back to the update function.

opts can be used to disable further event propagation.

let clickHandler = onWithOptions defaultOptions "click" emptyDecoder $ \() -> Action
in button_ [ clickHandler, class_ "add" ] [ text_ "+" ]

data Options Source #

Options for handling event propagation.

Constructors

Options 

Instances

Instances details
Eq Options Source # 
Instance details

Defined in Miso.Event.Types

Methods

(==) :: Options -> Options -> Bool #

(/=) :: Options -> Options -> Bool #

Show Options Source # 
Instance details

Defined in Miso.Event.Types

Generic Options Source # 
Instance details

Defined in Miso.Event.Types

Associated Types

type Rep Options :: Type -> Type #

Methods

from :: Options -> Rep Options x #

to :: Rep Options x -> Options #

ToJSVal Options Source # 
Instance details

Defined in Miso.Event.Types

type Rep Options Source # 
Instance details

Defined in Miso.Event.Types

type Rep Options = D1 ('MetaData "Options" "Miso.Event.Types" "miso-1.8.2.0-B5Z9gpR3wHYDZYus9qSuzV" 'False) (C1 ('MetaCons "Options" 'PrefixI 'True) (S1 ('MetaSel ('Just "preventDefault") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "stopPropagation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

defaultOptions :: Options Source #

Default value for Options.

defaultOptions = Options { preventDefault = False, stopPropagation = False }

Mouse events

Keyboard events

Form events

Focus events

onBlur :: action -> Attribute action Source #

blur event defined with custom options

https://developer.mozilla.org/en-US/docs/Web/Events/blur

Drag events

Drop events