@@ -1,44 +1,18 @@
4−Elm.Mouse = function() {
2+function nativeMouse(elm) {
7− /** position : Signal (Int,Int)
8− The current mouse position.
10 var position = Elm.Signal.constant(Value.Tuple(0,0));
3 var position = Elm.Signal.constant(Value.Tuple(0,0));
11 position.defaultNumberOfKids = 2;
4 position.defaultNumberOfKids = 2;
13− /** x : Signal Int
6+ // do not get rid of x and y. By setting their default number
14− The current x-coordinate of the mouse.
7+ // of kids, it is possible to detatch the mouse listeners if
15− **/
8+ // they are not needed.
16− var x = Elm.Signal.lift(function(p){return p[1];})(position);
9+ var x = Elm.Signal.lift(function(p){return p._0})(position);
17 x.defaultNumberOfKids = 0;
10 x.defaultNumberOfKids = 0;
20− The current y-coordinate of the mouse.
22− var y = Elm.Signal.lift(function(p){return p[2];})(position);
11+ var y = Elm.Signal.lift(function(p){return p._1})(position);
23 y.defaultNumberOfKids = 0;
12 y.defaultNumberOfKids = 0;
27− /** isDown : Signal Bool
28− The current state of the left mouse-button.
29− True when the button is down, and false otherwise.
31 var isDown = Elm.Signal.constant(false);
14 var isDown = Elm.Signal.constant(false);
33− /** isClicked : Signal Bool
34− True immediately after the left mouse-button has been clicked,
37 var isClicked = Elm.Signal.constant(false);
15 var isClicked = Elm.Signal.constant(false);
39− /** clicks : Signal ()
40− Always equal to unit. Event triggers on every mouse click.
42 var clicks = Elm.Signal.constant(Value.Tuple());
16 var clicks = Elm.Signal.constant(Value.Tuple());
44 function getXY(e) {
18 function getXY(e) {
@@ -80,12 +54,6 @@ Elm.Mouse = function() {
80 this.removeEventListener('mousemove',arguments.callee,false);
54 this.removeEventListener('mousemove',arguments.callee,false);
83− /** isClickedOn : Element -> (Element, Signal Bool)
84− Determine whether an element has been clicked. The resulting pair
85− is a signal of booleans that is true when its paired element has
86− been clicked. The signal is True immediately after the left
87− mouse-button has been clicked, and false otherwise.
89 var clickedOn = function(elem) {
57 var clickedOn = function(elem) {
90 var node = Render.render(elem);
58 var node = Render.render(elem);
91 var click = Elm.Signal.constant(false);
59 var click = Elm.Signal.constant(false);
@@ -95,12 +63,11 @@ Elm.Mouse = function() {
96 return Value.Tuple(Value.wrap(node), click);
64 return Value.Tuple(Value.wrap(node), click);
98− return {position: position,
66+ elm.Native.Mouse = {position: position,
101− isClicked: isClicked,
69+ isClicked: isClicked,
102− isDown: isDown,
70+ isDown: isDown,
103− clicks: clicks,
71+ clicks: clicks,
104− isClickedOn: clickedOn
72+ isClickedOn: clickedOn};