Module Note_brr_kit.MouseSource

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

Sourceval pt : float -> float -> float * float

pt x y is (x, y).

Sourcetype 'a events

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

Sourceval on_target : ?capture:bool -> ?propagate:bool -> ?default:bool -> ?normalize:bool -> (float -> float -> 'a) -> Brr.Ev.target -> '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.

Sourceval 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.

Sourceval 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

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

pos evs is the current mouse position in the target.

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

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

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

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

Mouse buttons

Sourceval 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.

Sourceval 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.

Sourceval 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.

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

mid is like left but the middle button.

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

mid_downis like left_down but for the middle button.

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

mid_up is like left_up but for the middle button.

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

right is like left but the right button.

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

right_downis like left_down but for the right button.

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

right_up is like left_up but for the right button.

Mouse cursors

Sourcemodule Cursor : sig ... end

Mouse cursors.