Module

Elmish.HTML.Events

Package
purescript-elmish-html
Repository
collegevine/purescript-elmish-html

This module defines types that are used as event objects in React built-in events, as well as some convenience functions on them.

#InputChangeEvent Source

newtype InputChangeEvent

Event object specifically for the onChange event of the <input> tag. While it doesn't have any special properties relative to SyntheticEvent, it's modeled as a separate type so as to support the custom accessors inputText and inputChecked, thus reducing the friction in the most frequent use case of:

input { type: "text", onChange: dispatch <| MyInputChanged <<< E.inputText }

input { type: "checkbox", onChange: dispatch <| MyCheckboxChanged <<< E.inputChecked }

Constructors

Instances

#KeyboardEvent Source

newtype KeyboardEvent

Event object for keyboard-related events such as onKeyDown or onKeyPress. This type follows React docs at https://reactjs.org/docs/events.html#keyboard-events

Constructors

Instances

#MouseEvent Source

newtype MouseEvent

Event object for mouse-related events such as onMouseDown or onMouseMove. This type follows React docs at https://reactjs.org/docs/events.html#mouse-events

Constructors

Instances

#SelectChangeEvent Source

newtype SelectChangeEvent

Event object specifically for the onChange event of the <select> tag. While it doesn't have any special properties relative to SyntheticEvent, it's modeled as a separate type so as to support the custom accessor selectSelectedValue, thus reducing the friction in the most frequent use case of:

select { onChange: dispatch <| MyInputChanged <<< E.selectSelectedValue }

Constructors

Instances

#SyntheticEvent Source

newtype SyntheticEvent

The most generic event object from React, for events that don't have any special properties. This type follows React docs at https://reactjs.org/docs/events.html

Constructors

Instances

#TextAreaChangeEvent Source

newtype TextAreaChangeEvent

Event object specifically for the onChange event of the <textarea> tag. While it doesn't have any special properties relative to SyntheticEvent, it's modeled as a separate type so as to support the custom accessor textareaText, thus reducing the friction in the most frequent use case of:

textarea { onChange: dispatch <| MyTextareaChanged <<< E.textareaText }

Constructors

Instances

#TouchEvent Source

newtype TouchEvent

Event object for touch-related events such as onTouchStart or onTouchMove. This type follows React docs at https://reactjs.org/docs/events.html#touch-events

Constructors

Instances

#inputChecked Source

inputChecked :: InputChangeEvent -> Boolean

Convenience accessor for extracting the checked state of an <input type=checkbox> tag in its onChange handler.

input { type: "checkbox", onChange: dispatch <| MyCheckboxChanged <<< E.inputChecked }

#inputText Source

inputText :: InputChangeEvent -> String

Convenience accessor for extracting the value of an <input type=text> tag in its onChange handler.

input { type: "text", onChange: dispatch <| MyInputChanged <<< E.inputText }

#selectSelectedValue Source

selectSelectedValue :: SelectChangeEvent -> String

Convenience accessor for extracting the selected value of a <select> tag in its onChange handler.

select { onChange: dispatch <| MyInputChanged <<< E.selectSelectedValue }

#textareaText Source

textareaText :: TextAreaChangeEvent -> String

Convenience accessor for extracting the value of a <textarea> tag in its onChange handler.

textarea { onChange: dispatch <| MyTextareaChanged <<< E.textareaText }

Re-exports from Elmish.Dispatch

#EventHandler Source

newtype EventHandler event

Type of event handling functions. This is the standard shape of all event handlers on React's built-in components (aka tags) and most third-party components as well. The constructor is intentionally hidden. Use the handle function to create instances of this type.

Instances

#Dispatch Source

type Dispatch msg = msg -> Effect Unit

A function that a view can use to report messages originating from JS/DOM.

#handle Source

handle :: forall event. Dispatch event -> EventHandler event

Create a React event handler from a function event -> Effect Unit.

Re-exports from Elmish.HTML.Events.Methods

#stopPropagation Source

stopPropagation :: forall e. IsSyntheticEvent e => e -> Effect Unit

Prevents propagation of the event up the React DOM tree. See also https://reactjs.org/docs/events.html

#preventDefault Source

preventDefault :: forall e. IsSyntheticEvent e => e -> Effect Unit

Prevents the default handling of the event by the browser. See also https://reactjs.org/docs/events.html

#getModifierState Source

getModifierState :: forall e. IsKeyboardOrMouseEvent e => String -> e -> Boolean

Returns the state of a given modifier key during an event, as defined in https://reactjs.org/docs/events.html#keyboard-events

This function applies only to certain kinds of events, such as MouseEvent or KeyboardEvent.