elm-community/html-extra/3.4.0

Html.Events.Extra

Additional decoders for use with event handlers in html.

Event decoders

  • TODO: key

  • TODO: code

  • TODO: KeyEvent, keyEvent

charCode : Decoder (Maybe Char)

Character code for key board events. This is being deprecated, but support for DOM3 Keyboard events is not yet present in most browsers.

Typed event decoders

targetValueFloat : Decoder Float

Floating-point target value.

targetValueInt : Decoder Int

Integer target value.

targetValueMaybe : Decoder (Maybe String)

String or empty target value.

targetValueMaybeFloat : Decoder (Maybe Float)

Floating-point or empty target value.

targetValueMaybeInt : Decoder (Maybe Int)

Integer or empty target value.

targetValueFloatParse : Decoder Float

Parse a floating-point value from the input instead of using valueAsNumber. Use this with inputs that do not have a number type.

targetValueIntParse : Decoder Int

Parse an integer value from the input instead of using valueAsNumber. Use this with inputs that do not have a number type.

targetValueMaybeFloatParse : Decoder (Maybe Float)

Parse an optional floating-point value from the input instead of using valueAsNumber. Use this with inputs that do not have a number type.

targetValueMaybeIntParse : Decoder (Maybe Int)

Parse an optional integer value from the input instead of using valueAsNumber. Use this with inputs that do not have a number type.

targetSelectedIndex : Decoder (Maybe Int)

Parse the index of the selected option of a select. Returns Nothing in place of the spec's magic value -1.

targetSelectedOptions : Decoder (List String)

Parse event.target.selectedOptions and return option values.

Event Handlers

onClickPreventDefault : msg -> Attribute msg

Always send msg upon click, preventing the browser's default behavior.

onClickStopPropagation : msg -> Attribute msg

Always send msg upon click, preventing click propagation.

Always send msg upon click, preventing the browser's default behavior and propagation

onEnter : msg -> Attribute msg

When the enter key is released, send the msg. Otherwise, do nothing.

onChange : (String -> msg) -> Attribute msg

An HTML Event attribute that passes the event.target.value to a msg constructor when an input, select, or textarea element has changed.

onMultiSelect : (List String -> msg) -> Attribute msg

Detect change events on multi-choice select elements.

It will grab the string values of event.target.selectedOptions on any change event.

Check out targetSelectedOptions for more details on how this works.

Note: onChange parses event.target.value that doesn't work with multi-choice select elements.

Note 2: selectedOptions is not supported by Internet Explorer.