Reputation: 4020
I have a div in js_of_ocaml which I want to assign an onmouseover event, like
deck_div##onmouseover <- (fun () -> (* do stuff *) )
However, the function type expected is
(Dom_html.divElement Js.t, Dom_html.mouseEvent Js.t) Dom_html.event_listener
How to construct this event listener? deck_div
has no method addEventListener
.
Upvotes: 3
Views: 634
Reputation: 2839
I was thinking about same question some months ago and AFAIR I have succeeded with Html.handler. Maybe this example will help you
https://github.com/ocsigen/js_of_ocaml/blob/master/examples/hyperbolic/hypertree.ml#L276
let handle_drag element move stop click =
let fuzz = 4 in
element##onmousedown <- Html.handler
(fun ev ->
let x0 = ev##clientX and y0 = ev##clientY in
....
Upvotes: 5