lustre/event

Functions

pub fn checked(event: Dynamic) -> Result(Bool, List(DecodeError))

A helpful decoder to extract the checked property from an event triggered by a checkbox.

pub fn mouse_position(event: Dynamic) -> Result(
  #(Float, Float),
  List(DecodeError),
)

A helpful decoder to grab the mouse’s current x and y position in the viewport from an event object.

pub fn on(name: String, handler: fn(Dynamic) -> Option(a)) -> Attribute(
  a,
)
pub fn on_blur(msg: a) -> Attribute(a)
pub fn on_check(msg: fn(Bool) -> a) -> Attribute(a)
pub fn on_click(msg: a) -> Attribute(a)
pub fn on_focus(msg: a) -> Attribute(a)
pub fn on_input(msg: fn(String) -> a) -> Attribute(a)
pub fn on_keydown(msg: fn(String) -> a) -> Attribute(a)

Listens for key dow events on an element, and dispatches a message with the current key being pressed.

pub fn on_keypress(msg: fn(String) -> a) -> Attribute(a)

Listens for key presses on an element, and dispatches a message with the current key being pressed.

pub fn on_keyup(msg: fn(String) -> a) -> Attribute(a)

Listens for key up events on an element, and dispatches a message with the current key being released.

pub fn on_mouse_down(msg: a) -> Attribute(a)
pub fn on_mouse_enter(msg: a) -> Attribute(a)
pub fn on_mouse_leave(msg: a) -> Attribute(a)
pub fn on_mouse_out(msg: a) -> Attribute(a)
pub fn on_mouse_over(msg: a) -> Attribute(a)
pub fn on_mouse_up(msg: a) -> Attribute(a)
pub fn on_submit(msg: a) -> Attribute(a)
pub fn value(event: Dynamic) -> Result(String, List(DecodeError))

A helpful decoder to extract the value from an event object. This is handy for getting the value as a string from an input event, for example.

Search Document