package brr

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

DOM events.

Event types

type 'a type'

The type for events which can pose as values of type 'a. See the predefined event types.

module Type : sig ... end

Event types.

type void = Type.void type'

The type for events that do not expose further data.

Events

type target

The type for EventTarget abiding objects.

type init

The type for event initialisation objects.

val init : ?bubbles:bool -> ?cancelable:bool -> ?composed:bool -> unit -> init

init is an event initialisation object with given parameters.

type 'a t

The type for Event objects which can pose as events of type 'a.

type 'a event

See t.

val create : ?init:init -> 'a type' -> 'a t

create ?init t is an event of type t initialised with init.

val as_type : 'a t -> 'a

as_type e specialises the event to its type.

val type' : 'a t -> 'a type'

type' e is the type of e.

val target : 'a t -> target

target e is the target on which e was originally dispatched.

val current_target : 'a t -> target

current_target e is the target currently handling e. See also target.

val composed_path : 'a t -> target list

composed_path e are the targets on which listeners will be invoked.

val event_phase : 'a t -> [ `None | `Capturing | `At_target | `Bubbling ]

event_phase e is e's event phase, see here for details. This picture may help.

val bubbles : 'a t -> bool

bubbles e is true whether the event can bubble up through the DOM.

val stop_propagation : 'a t -> unit

stop_propagation e prevents the propagation of e in the DOM, remaining handlers of e on the current_target are still invoked use stop_immediate_propagation to stop these. The user agent's default action for e still occurs, use prevent_default to prevent that.

val stop_immediate_propagation : 'a t -> unit

stop_immediate_propagation e is like stop_propagation but it also prevents the invocation of other handlers for e that may be listening on the current_target.

val cancelable : 'a t -> bool

cancelable e indicates whether e can be cancelled, that is whether prevent_default will succeed.

val prevent_default : 'a t -> unit

prevent_default e prevents the user agent's default action for e to happen. This may have no effect if cancelable is false, see default_prevented.

val default_prevented : 'a t -> bool

default_prevented e is true indicates whether a call to prevent_default succeded.

val composed : 'a t -> bool

composed e is the composed property of e.

val is_trusted : 'a t -> bool

is_trusted e is true if e was dispatched by the user agent and false otherwise.

val timestamp_ms : 'a t -> float

timestamp_ms e is the time in milleseconds since the POSIX epoch when the event was created.

val dispatch : 'a t -> target -> bool

dispatch e t dispatches event e on target t.

Listening

type listen_opts

The type for listening options.

val listen_opts : ?capture:bool -> ?once:bool -> ?passive:bool -> unit -> listen_opts

listen_opts () are options for listen.

  • capture indicates if events are listened before being dispatched to descendents of the target in the DOM tree. Defaults to false.
  • once indicates at most a single event will be listened. If true the listener is automatically removed when invoked. Defaults to false.
  • passive indicates the listener never calls prevent_default on the event. If it does nothing will happen (except maybe a console warning). Defaults to false.
val listen : ?opts:listen_opts -> 'a type' -> ('a t -> unit) -> target -> unit

listen ~opts type' f t listens for events of type type' on target t with function f and options opts (see listen_opts for defaults).

val unlisten : ?opts:listen_opts -> 'a type' -> ('a t -> unit) -> target -> unit

unlisten ~opts type' f stops the listening introduced by the corresponding listen invocation.

val next : ?capture:bool -> 'a type' -> target -> 'a t Fut.t

next type' t is a future that determines the next event of type type' on target t. For capture see listen_opts.

Event subobjects

module Data_transfer : sig ... end

DataTransfer objects.

module Clipboard : sig ... end

Clipboard events.

module Composition : sig ... end

Composition events.

module Error : sig ... end

Error events.

module Extendable : sig ... end

Extendable events.

module Focus : sig ... end

Focus events.

module Hash_change : sig ... end

Hash change events

module Input : sig ... end

Input events.

module Keyboard : sig ... end

Keyboard events.

module Mouse : sig ... end

Mouse events.

module Drag : sig ... end

Drag events.

module Pointer : sig ... end

Pointer events

module Wheel : sig ... end

Wheel events.

Predefined types

Due to type dependencies some events are defined in their dedicated modules:

Events that have no special type dependencies are defined here, in alphabetic order.

val abort : void

abort is the type for abort events.

val activate : Extendable.t type'

activate is the activate event.

val auxclick : Mouse.t type'

The type for auxclick events.

val beforeinput : Input.t type'

beforeinput is the beforeinput event.

val beforeunload : void

beforeunload is the beforeunload event.

val blur : Focus.t type'

blur is the blur event.

val canplay : void

canplay is the type for canplay events

val canplaythrough : void

canplaythrough is the type for canplaythrough events

val change : void

change is the change event.

val click : Mouse.t type'

The type for click events.

val clipboardchange : Clipboard.t type'

change is the clipboardchange event.

val close : void

close is the type for close events.

val compositionend : Composition.t type'

compositionstend is the compositionend event.

val compositionstart : Composition.t type'

compositionstart is the compositionstart event.

val compositionudpate : Composition.t type'

compositionstupdate is the compositionupdate event.

val controllerchange : void

controllerchange is the controllerchange event.

val copy : Clipboard.t type'

copy is the copy event.

val cut : Clipboard.t type'

cut is the cut event.

val dblclick : Mouse.t type'

The type for dblclick events.

val dom_content_loaded : void

dom_content_loaded is the type for DOMContentLoaded_event events.

val drag : Drag.t type'

drag is the drag event.

val dragend : Drag.t type'

dragend is the dragend event.

val dragenter : Drag.t type'

dragenter is the dragenter event.

val dragexit : Drag.t type'

dragexit is the dragexit event.

val dragleave : Drag.t type'

dragleave is the dragleave event.

val dragover : Drag.t type'

dragover is the dragover event.

val dragstart : Drag.t type'

dragstart is the dragstart event.

val drop : Drag.t type'

drop is the drop event.

val durationchange : void

durationchange is the type for durationchange events

val emptied : void

emptied is the type for emptied events

val ended : void

ended is the type for ended events

val error : Error.t type'

error is the type for error events.

val focus : Focus.t type'

focus is the focus event.

val focusin : Focus.t type'

focusin is the focusin event.

val focusout : Focus.t type'

focusout is the focusout event.

val fullscreenchange : void

fullscreenchange is the fullscreenchange event.

val fullscreenerror : void

fullscreenerror is the fullscreenerror event.

val gotpointercapture : Pointer.t type'

gotpointercaputer is the gotpointercapture event.

val hashchange : Hash_change.t type'

hashchange is the type for hashchange events

val input : Input.t type'

input is the input event.

val install : Extendable.t type'

install is the install event.

val keydown : Keyboard.t type'

keydown is the keydown event

val keyup : Keyboard.t type'

keyup is the keyup event

val languagechange : void

languagechange is the type type for languagechange events.

val load : void

load is the type for load events.

val loadeddata : void

loadeddata is the type for loadeddata events

val loadedmetadata : void

loadedmetadata is the type for loadedmetadata events

val loadstart : void

loadstart is the type for loadstart events

val lostpointercapture : Pointer.t type'

lostpointercapture is the lostpointercaptpure event.

val mousedown : Mouse.t type'

mousedown is the type for mousedown events.

val mouseenter : Mouse.t type'

mouseenter is the type for mouseenter events.

val mouseleave : Mouse.t type'

mouseleave is the type for mouseleave events.

val mousemove : Mouse.t type'

mousemove is the type for mousemove events.

val mouseout : Mouse.t type'

mouseout is the type for mouseout events.

val mouseover : Mouse.t type'

mouseover is the type for mouseover events.

val mouseup : Mouse.t type'

mouseup is the type for mouseup events.

val open' : void

open' is the type for open events.

val paste : Clipboard.t type'

paste is the paste event.

val pause : void

pause is the type for pause events

val play : void

play is the type for play events

val playing : void

playing is the type for playing events

val pointercancel : Pointer.t type'

pointercancel is the pointercancel event.

val pointerdown : Pointer.t type'

pointerdown is the pointerdown event.

val pointerenter : Pointer.t type'

pointerneter is the pointerenter event.

val pointerleave : Pointer.t type'

pointerleave is the pointerleave event.

val pointerlockchange : void

pointerlockchange is the pointerlockchange event.

val pointerlockerror : void

pointerlockerror is the pointerlockerror event.

val pointermove : Pointer.t type'

pointemove is the pointermove event.

val pointerout : Pointer.t type'

pointerout is the pointerout event.

val pointerover : Pointer.t type'

pointerover is the pointerover event.

val pointerrawupdate : Pointer.t type'

pointerrawupdate is the pointerrawupdate event.

val pointerup : Pointer.t type'

pointerup is the pointerup event.

val progress : void

progress is the type for progress events

val ratechange : void

ratechange is the type for ratechange events

val reset : void

The type for reset events.

val resize : void

resize is the resize event.

val scroll : void

scroll is the scroll event.

val seeked : void

seeked is the type for seeked events

val seeking : void

seeking is the type for seeking events

val select : void

select is the type for select events.

val statechange : void

statechange is the type for statechange events.

val stalled : void

stalled is the type for stalled events

val suspend : void

suspend is the type for suspend events

val timeupdate : void

timeupdate is the type for timeupdate events

val unload : void

unload is the type for unload events.

val updatefound : void

updatefound is the type for updatefound events.

val visibilitychange : void

visibilitychange is the type for visibilitychange events.

val volumechange : void

volumechange is the type for volumechange events

val waiting : void

waiting is the type for waiting events

val wheel : Wheel.t type'

The type for wheel events.