Module Brr.Ev

DOM events

Events and event kinds

type 'a target = Js_of_ocaml.Dom_html.#eventTarget as a Js_of_ocaml.Js.t

The type for event targets.

type 'a kind = Js_of_ocaml.Dom_html.#event as a Js_of_ocaml.Js.t Js_of_ocaml.Dom_html.Event.typ

The type for kind of events. See Event kinds.

type 'a t = Js_of_ocaml.Dom_html.#event as a Js_of_ocaml.Js.t

The type for events.

Events as Note events

val for_target : ?⁠capture:bool -> ?⁠propagate:bool -> ?⁠default:bool -> 'a target -> 'b kind -> ('b t -> 'c) -> 'c Note.event

for_target ~capture ~propagate ~default t k f is an event that reports events of kind k transformed by f on target t. If capture is true the event occurs during the capture phase (defaults to false). If propagate is true (default) the event is propagated. The default action is performed iff default is true (defaults to the value of propagate).

val for_targets : ?⁠capture:bool -> ?⁠propagate:bool -> ?⁠default:bool -> 'a target list -> 'b kind -> ('a target -> 'b t -> 'c) -> 'c Note.event

for_targets is like for_target except the event occurs for the event kind on the given list of targets.

val for_el : ?⁠capture:bool -> ?⁠propagate:bool -> ?⁠default:bool -> El.t -> 'b kind -> ('b t -> 'c) -> 'c Note.event

for_el is like for_target except the target is an element.

val for_els : ?⁠capture:bool -> ?⁠propagate:bool -> ?⁠default:bool -> El.t list -> 'b kind -> (El.t -> 'b t -> 'c) -> 'c Note.event

for_els is like for_targets excepts the targets are elements.

Event mappers

val ev : 'b t -> 'b t

ev e is e.

val unit : 'b t -> unit

unit e is ().

val stamp : 'a -> 'b t -> 'a

stamp v e is v.

Event callbacks

Lower-level convenience interface.

type cb

The type for event callbacks.

type cb_ret

The type for callback return.

val add_cb : ?⁠capture:bool -> 'a target -> 'b kind -> ('a target -> 'b t -> cb_ret) -> cb

add_cb ~capture t k f calls f e ev whenever an event ev of kind k occurs on t. If capture is true the callback occurs during the capture phase (defaults to false).

val rem_cb : cb -> unit

rem_cb cb removes the callback cb.

val cb_ret : ?⁠propagate:bool -> ?⁠default:bool -> 'a t -> cb_ret

cb_ret ~propagate ~default ev returns from the callback and propagates event ev if propagate is true (default). The default action is performed iff default is true (defaults to the value of propagate.

Event kinds

MDN's web docs Event reference.

val kind : string -> 'a kind
val abort : Js_of_ocaml.Dom_html.event kind
val afterprint : Js_of_ocaml.Dom_html.event kind
val beforeprint : Js_of_ocaml.Dom_html.event kind
val beforeunload : Js_of_ocaml.Dom_html.event kind
val blur : Js_of_ocaml.Dom_html.event kind
val cached : Js_of_ocaml.Dom_html.event kind
val change : Js_of_ocaml.Dom_html.event kind
val click : Js_of_ocaml.Dom_html.event kind
val dblclick : Js_of_ocaml.Dom_html.event kind
val domContentLoaded : Js_of_ocaml.Dom_html.event kind
val error : Js_of_ocaml.Dom_html.event kind
val focus : Js_of_ocaml.Dom_html.event kind
val hashchange : Js_of_ocaml.Dom_html.event kind
val input : Js_of_ocaml.Dom_html.event kind
val invalid : Js_of_ocaml.Dom_html.event kind
val keydown : Js_of_ocaml.Dom_html.keyboardEvent kind
val keypress : Js_of_ocaml.Dom_html.keyboardEvent kind
val keyup : Js_of_ocaml.Dom_html.keyboardEvent kind
val load : Js_of_ocaml.Dom_html.event kind
val message : Js_of_ocaml.Dom_html.event kind
val mousedown : Js_of_ocaml.Dom_html.mouseEvent kind
val mouseenter : Js_of_ocaml.Dom_html.mouseEvent kind
val mouseleave : Js_of_ocaml.Dom_html.mouseEvent kind
val mousemove : Js_of_ocaml.Dom_html.mouseEvent kind
val mouseout : Js_of_ocaml.Dom_html.mouseEvent kind
val mouseover : Js_of_ocaml.Dom_html.mouseEvent kind
val mouseup : Js_of_ocaml.Dom_html.mouseEvent kind
val offline : Js_of_ocaml.Dom_html.event kind
val online : Js_of_ocaml.Dom_html.event kind
val pagehide : Js_of_ocaml.Dom_html.event kind
val pageshow : Js_of_ocaml.Dom_html.event kind
val popstate : Js_of_ocaml.Dom_html.event kind
val progress : Js_of_ocaml.Dom_html.event kind
val readystatechange : Js_of_ocaml.Dom_html.event kind
val reset : Js_of_ocaml.Dom_html.event kind
val resize : Js_of_ocaml.Dom_html.event kind
val submit : Js_of_ocaml.Dom_html.event kind
val unload : Js_of_ocaml.Dom_html.event kind