Get rid of isClicked
It can be argued that everything should be derived from isDown and position (the two real facts about the mouse), so maybe that is a direction to go from here.
This commit is contained in:
parent
50c2618d3a
commit
007ea7126f
2 changed files with 3 additions and 12 deletions
|
@ -7,7 +7,7 @@ module Mouse where
|
||||||
@docs position, x, y
|
@docs position, x, y
|
||||||
|
|
||||||
# Button Status
|
# Button Status
|
||||||
@docs isDown, clicks, isClicked
|
@docs isDown, clicks
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
@ -31,11 +31,6 @@ True when the button is down, and false otherwise. -}
|
||||||
isDown : Signal Bool
|
isDown : Signal Bool
|
||||||
isDown = Native.Mouse.isDown
|
isDown = Native.Mouse.isDown
|
||||||
|
|
||||||
{-| True immediately after the left mouse-button has been clicked,
|
|
||||||
and false otherwise. -}
|
|
||||||
isClicked : Signal Bool
|
|
||||||
isClicked = Native.Mouse.isClicked
|
|
||||||
|
|
||||||
{-| Always equal to unit. Event triggers on every mouse click. -}
|
{-| Always equal to unit. Event triggers on every mouse click. -}
|
||||||
clicks : Signal ()
|
clicks : Signal ()
|
||||||
clicks = Native.Mouse.clicks
|
clicks = Native.Mouse.clicks
|
||||||
|
|
|
@ -20,15 +20,12 @@ Elm.Native.Mouse.make = function(elm) {
|
||||||
y.defaultNumberOfKids = 0;
|
y.defaultNumberOfKids = 0;
|
||||||
|
|
||||||
var isDown = Signal.constant(false);
|
var isDown = Signal.constant(false);
|
||||||
var isClicked = Signal.constant(false);
|
|
||||||
var clicks = Signal.constant(Utils.Tuple0);
|
var clicks = Signal.constant(Utils.Tuple0);
|
||||||
|
|
||||||
var node = elm.display === ElmRuntime.Display.FULLSCREEN ? document : elm.node;
|
var node = elm.display === ElmRuntime.Display.FULLSCREEN ? document : elm.node;
|
||||||
|
|
||||||
elm.addListener([isClicked.id, clicks.id], node, 'click', function click() {
|
elm.addListener([clicks.id], node, 'click', function click() {
|
||||||
elm.notify(isClicked.id, true);
|
|
||||||
elm.notify(clicks.id, Utils.Tuple0);
|
elm.notify(clicks.id, Utils.Tuple0);
|
||||||
elm.notify(isClicked.id, false);
|
|
||||||
});
|
});
|
||||||
elm.addListener([isDown.id], node, 'mousedown', function down() {
|
elm.addListener([isDown.id], node, 'mousedown', function down() {
|
||||||
elm.notify(isDown.id, true);
|
elm.notify(isDown.id, true);
|
||||||
|
@ -44,8 +41,7 @@ Elm.Native.Mouse.make = function(elm) {
|
||||||
position: position,
|
position: position,
|
||||||
x:x,
|
x:x,
|
||||||
y:y,
|
y:y,
|
||||||
isClicked: isClicked,
|
|
||||||
isDown: isDown,
|
isDown: isDown,
|
||||||
clicks: clicks
|
clicks: clicks
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue