miso
Copyright(C) 2016-2026 David M. Johnson
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <code@dmj.io>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Miso.Event.Types

Description

Overview

Miso.Event.Types defines the payload types for browser DOM events and the Events map that controls which events are delegated to the miso runtime and at which Phase of the event lifecycle.

Event delegation

Miso uses event delegation: a single listener is attached at the root of the component's DOM subtree and catches all matching events as they bubble or capture past it. The Events map (Map MisoString Phase) declares which event names participate and their phase.

The default set (defaultEvents) covers the most common interactions. Additional event groups can be merged in when constructing a component:

myComponent = (component model update view)
  { events = defaultEvents
      <> keyboardEvents
      <> pointerEvents
  }

Event groups

defaultEvents
blur, change, click, contextmenu, dblclick, focus, input, select, submit
keyboardEvents
keydown, keypress, keyup
mouseEvents
mouseup, mousedown, mouseenter, mouseleave, mouseover, mouseout, contextmenu
dragEvents
drag, dragstart, dragend, dragenter, dragleave, dragover, drop
pointerEvents
pointerup, pointerdown, pointerenter, pointerleave, pointerover, pointerout, pointercancel, contextmenu
mediaEvents
play, pause, ended, timeupdate, volumechange, …
clipboardEvents
cut, copy, paste
touchEvents
touchstart, touchend, touchmove, touchcancel

Payload types

See also

Synopsis

Types

type Events = Map MisoString Phase Source #

Convenience type for Events

data Phase Source #

Phase during which event listener is invoked.

Since: 1.9.0.0

Constructors

CAPTURE 
BUBBLE 

Instances

Instances details
Show Phase Source # 
Instance details

Defined in Miso.Event.Types

Methods

showsPrec :: Int -> Phase -> ShowS #

show :: Phase -> String #

showList :: [Phase] -> ShowS #

Eq Phase Source # 
Instance details

Defined in Miso.Event.Types

Methods

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

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

ToJSVal Phase Source # 
Instance details

Defined in Miso.Event.Types

Methods

toJSVal :: Phase -> IO JSVal Source #

KeyboardEvent

data KeyInfo Source #

Type useful for both KeyCode and additional key press information.

Constructors

KeyInfo 

Fields

Instances

Instances details
Show KeyInfo Source # 
Instance details

Defined in Miso.Event.Types

Eq KeyInfo Source # 
Instance details

Defined in Miso.Event.Types

Methods

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

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

newtype KeyCode Source #

Constructors

KeyCode Int 

Instances

Instances details
Num KeyCode Source # 
Instance details

Defined in Miso.Event.Types

Show KeyCode Source # 
Instance details

Defined in Miso.Event.Types

Eq KeyCode Source # 
Instance details

Defined in Miso.Event.Types

Methods

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

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

Ord KeyCode Source # 
Instance details

Defined in Miso.Event.Types

FromJSON KeyCode Source # 
Instance details

Defined in Miso.Event.Types

CheckedEvent

newtype Checked Source #

Type used for Checkbox events.

Constructors

Checked Bool 

Instances

Instances details
Show Checked Source # 
Instance details

Defined in Miso.Event.Types

Eq Checked Source # 
Instance details

Defined in Miso.Event.Types

Methods

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

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

Ord Checked Source # 
Instance details

Defined in Miso.Event.Types

FromJSON Checked Source # 
Instance details

Defined in Miso.Event.Types

PointerEvent

data PointerEvent Source #

Type used for Pointer events. https://w3c.github.io/pointerevents

Constructors

PointerEvent 

Fields

Instances

Instances details
Show PointerEvent Source # 
Instance details

Defined in Miso.Event.Types

Eq PointerEvent Source # 
Instance details

Defined in Miso.Event.Types

Options

data Options Source #

Options for handling event propagation.

Constructors

Options 

Fields

Instances

Instances details
Monoid Options Source # 
Instance details

Defined in Miso.Event.Types

Semigroup Options Source # 
Instance details

Defined in Miso.Event.Types

Show Options Source # 
Instance details

Defined in Miso.Event.Types

Eq Options Source # 
Instance details

Defined in Miso.Event.Types

Methods

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

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

ToJSVal Options Source # 
Instance details

Defined in Miso.Event.Types

defaultOptions :: Options Source #

Default value for Options.

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

preventDefault :: Options Source #

Smart constructor for specifying preventDefault

Since: 1.9.0.0

stopPropagation :: Options Source #

Smart constructor for specifying stopPropagation

Since: 1.9.0.0

Events

defaultEvents :: Events Source #

Default delegated events

keyboardEvents :: Events Source #

Keyboard events

mouseEvents :: Events Source #

Mouse events

dragEvents :: Events Source #

Drag events

pointerEvents :: Events Source #

Pointer events

mediaEvents :: Events Source #

Audio video events For use with the audio and video tags.

myApp :: App Model Action
myApp = (component model update view){ events = defaultEvents <> mediaEvents }

clipboardEvents :: Events Source #

Clipboard events

touchEvents :: Events Source #

Touch events