Module Brr.Mouse

module Mouse: sig .. end
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 for_target : ?capture:bool ->
?propagate:bool ->
?default:bool ->
?normalize:bool ->
#Dom_html.eventTarget Brr.Ev.target ->
(float -> float -> 'a) -> 'a events
for_target t pt 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.Ev.for_target.
val for_el : ?capture:bool ->
?propagate:bool ->
?default:bool ->
?normalize:bool -> Brr.El.t -> (float -> float -> 'a) -> 'a events
for_el is like Brr.Mouse.for_target but for an element. Note that Brr.Mouse.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 Brr.Mouse.left but the middle button.
val mid_down : 'a events -> 'a Note.event
mid_downis like Brr.Mouse.left_down but for the middle button.
val mid_up : 'a events -> 'a Note.event
mid_up is like Brr.Mouse.left_up but for the middle button.
val right : 'a events -> bool Note.signal
right is like Brr.Mouse.left but the right button.
val right_down : 'a events -> 'a Note.event
right_downis like Brr.Mouse.left_down but for the right button.
val right_up : 'a events -> 'a Note.event
right_up is like Brr.Mouse.left_up but for the right button.