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.
#EventHandler Source
type EventHandler a = EffectFn1 a UnitType of every onXyz property on every HTML tag in this library. This is
the standard shape of all event handlers on React's built-in components
(aka tags).
#InputChangeEvent Source
newtype InputChangeEventEvent 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 KeyboardEventEvent 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 MouseEventEvent 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 SelectChangeEventEvent 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 SyntheticEventThe 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 TextAreaChangeEventEvent 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 TouchEventEvent 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 -> BooleanConvenience 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 -> StringConvenience 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 -> StringConvenience accessor for extracting the selected value of a <select> tag
in its onChange handler.
select { onChange: dispatch <| MyInputChanged <<< E.selectSelectedValue }
#textareaText Source
textareaText :: TextAreaChangeEvent -> StringConvenience accessor for extracting the value of a <textarea> tag
in its onChange handler.
textarea { onChange: dispatch <| MyTextareaChanged <<< E.textareaText }
Re-exports from Elmish.Dispatch
#handleEffect Source
handleEffect :: forall event f. HandleEffect event f => f -> EffectFn1 event UnitAn escape-hatch way to create an event handler for when neither
handle nor handleMaybe are appropriate, which usually happens when
the event handler must do something else, besides dispatching a
message.
The argument may be either an Effect Unit or a function from the
event object to Effect Unit. If a message needs to be dispatched, the
consuming code is expected to do it via calling the Dispatch function
directly.
div
{ onKeyDown: E.handleEffect \(E.KeyboardEvent e) -> do
window >>= localStorage >>= setItem "Last key pressed" e.key
dispatch PressedKey
, onClick: E.handleEffect \e -> do
E.stopPropagation e
dispatch ClickedDiv
}
Re-exports from Elmish.HTML.Events.Methods
#stopPropagation Source
stopPropagation :: forall e. IsSyntheticEvent e => e -> Effect UnitPrevents 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 UnitPrevents 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 -> BooleanReturns 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.