Module Unicorn_jsoo.E

HTML events.

Just like attributes, events are specified inside the HTML node children and attach to their closest parent.

val click : ( 'a -> 'a ) -> 'a t

click fn invokes the callback fn when its HTML parent node is clicked.

  • ∀ f g. click f & click g == click (fun x -> g (f x))
  • ∀ i f. iso i (click f) == click (Iso.map i f) and same for lenses and prisms
val doubleclick : ( 'a -> 'a ) -> 'a t
val keydown : ( int -> 'a -> 'a ) -> 'a t
val blur : ( 'a -> 'a ) -> 'a t

Lifecycle

val init : ( Js_of_ocaml.Dom_html.element Js_of_ocaml.Js.t -> 'a -> 'a ) -> 'a t

init fn calls fn once on the creation of the HTML widget.

val init_focus : unit -> 'a t

init_focus () focuses the HTML parent element on creation.

Animations

val now : ( float -> 'a -> 'a ) -> 'a t

now fn invokes the callback fn on every frame with the current time and state.

val dt : ( float -> 'a -> 'a ) -> 'a t

dt fn invokes the callback fn on every frame with the delta time and state.

Unsafe

Consider submitting a PR if you find yourself using this!

val make : _ Js_of_ocaml.Dom.event Js_of_ocaml.Js.t as 'e Js_of_ocaml.Dom_html.Event.typ -> ( 'e -> 'a -> 'a ) -> 'a t

make ev callback attaches a new event handler to the HTML parent node.