lustre_pipes/event
Functions
pub fn checked(event: Dynamic) -> Result(Bool, List(DecodeError))
Similar to value
, decoding a checkbox’s checked
state is common
enough to warrant a dedicated decoder. This attempts to decode
event.target.checked
as a boolean.
pub fn mouse_position(
event: Dynamic,
) -> Result(#(Float, Float), List(DecodeError))
Decodes the mouse position from any event that has a clientX
and clientY
property.
pub fn on(
scaffold: #(String, List(Attribute(a))),
name: String,
handler: fn(Dynamic) -> Result(a, List(DecodeError)),
) -> #(String, List(Attribute(a)))
Listens for the given event and applies the handler to the event object. If
the handler returns an Ok
the resulting message will be dispatched, otherwise
the event (and any decoding error) will be ignored.
The event name is typically an all-lowercase string such as “click” or “mousemove”. If you’re listening for non-standard events (like those emitted by a custom element) their event names might be slightly different.
pub fn on_blur(
scaffold: #(String, List(Attribute(a))),
msg: a,
) -> #(String, List(Attribute(a)))
pub fn on_check(
scaffold: #(String, List(Attribute(a))),
msg: fn(Bool) -> a,
) -> #(String, List(Attribute(a)))
pub fn on_click(
scaffold: #(String, List(Attribute(a))),
msg: a,
) -> #(String, List(Attribute(a)))
pub fn on_focus(
scaffold: #(String, List(Attribute(a))),
msg: a,
) -> #(String, List(Attribute(a)))
pub fn on_input(
scaffold: #(String, List(Attribute(a))),
msg: fn(String) -> a,
) -> #(String, List(Attribute(a)))
pub fn on_keydown(
scaffold: #(String, List(Attribute(a))),
msg: fn(String) -> a,
) -> #(String, List(Attribute(a)))
Listens for key down events on an element, and dispatches a message with the current key being pressed.
pub fn on_keypress(
scaffold: #(String, List(Attribute(a))),
msg: fn(String) -> a,
) -> #(String, List(Attribute(a)))
Listens for key presses on an element, and dispatches a message with the current key being pressed.
pub fn on_keyup(
scaffold: #(String, List(Attribute(a))),
msg: fn(String) -> a,
) -> #(String, List(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(
scaffold: #(String, List(Attribute(a))),
msg: a,
) -> #(String, List(Attribute(a)))
pub fn on_mouse_enter(
scaffold: #(String, List(Attribute(a))),
msg: a,
) -> #(String, List(Attribute(a)))
pub fn on_mouse_leave(
scaffold: #(String, List(Attribute(a))),
msg: a,
) -> #(String, List(Attribute(a)))
pub fn on_mouse_out(
scaffold: #(String, List(Attribute(a))),
msg: a,
) -> #(String, List(Attribute(a)))
pub fn on_mouse_over(
scaffold: #(String, List(Attribute(a))),
msg: a,
) -> #(String, List(Attribute(a)))
pub fn on_mouse_up(
scaffold: #(String, List(Attribute(a))),
msg: a,
) -> #(String, List(Attribute(a)))
pub fn on_submit(
scaffold: #(String, List(Attribute(a))),
msg: a,
) -> #(String, List(Attribute(a)))
Listens for the form’s submit
event, and dispatches the given message. This
will automatically call prevent_default
to stop the form
from submitting.