Module Brr_note_kit.Mouse

User mouse.

Excepts for mouse ups, mouse events are only reported whenever the mouse is over the specified target.

By default coordinates are in target normalized coordinates with (0, 0) corresponding to the bottom left corner and (1,1) to the top right corner.

Mouse events

val pt : float -> float -> float * float

pt x y is (x, y).

type 'a events

The type for gathering mouse events on a given target and using 'a to represent points.

val on_target : ?⁠capture:bool -> ?⁠propagate:bool -> ?⁠default:bool -> ?⁠normalize:bool -> (float -> float -> 'a) -> -> 'a events

on_target pt t is mouse events for target t using pt to construct points. If normalize is true (default) coordinates are reported in target normalized coordinates (see above), if false they are reported in pixels with the origin at the top-left of the element. The other parameters are those from Brr_note.Evr.on_target.

val on_el : ?⁠capture:bool -> ?⁠propagate:bool -> ?⁠default:bool -> ?⁠normalize:bool -> (float -> float -> 'a) -> Brr.El.t -> 'a events

on_el is like on_target but for an element. Note that destroy automatically gets called with the result whenever the element is removed from the HTML DOM.

val destroy : 'a events -> unit

destroy evs removes the callbacks registred by evs. It's important to perform this whenever you no longer need the events as evs needs to register callbacks with the document to correctly capture mouse ups.

Mouse position

val pos : 'a events -> 'a Note.signal

pos evs is the current mouse position in the target.

val dpos : 'a events -> 'a Note.event

dpos evs occurs on mouse moves with current mouse position minus the previous position.

val mem : 'a events -> bool Note.signal

mem evs is true whenever the mouse position is inside the target.

Mouse buttons

val left : 'a events -> bool Note.signal

left evs is true whenever the left mouse button went down in the target and did not go up yet.

val left_down : 'a events -> 'a Note.event

left_down evs has an occurence with the mouse position whenever the button goes down in the target.

val left_up : 'a events -> 'a Note.event

left_up evs is true whenever the left mouse button went down in the target and goes back up anywhere. Note that the reported position might not be in the target.

val mid : 'a events -> bool Note.signal

mid is like left but the middle button.

val mid_down : 'a events -> 'a Note.event

mid_downis like left_down but for the middle button.

val mid_up : 'a events -> 'a Note.event

mid_up is like left_up but for the middle button.

val right : 'a events -> bool Note.signal

right is like left but the right button.

val right_down : 'a events -> 'a Note.event

right_downis like left_down but for the right button.

val right_up : 'a events -> 'a Note.event

right_up is like left_up but for the right button.

Mouse cursors

module Cursor : sig ... end

Mouse cursors.