In Elm, using Canvas rendering, you must use the signal Mouse.clicks
and respond to signal changes. Here is an example that will work:
import Graphics.Element exposing (Element, show)
import Mouse
clicks : Signal (Int, Int)
clicks =
Signal.sampleOn Mouse.clicks Mouse.position
main : Signal Element
main =
Signal.map show clicks
In essence, these Mouse.clicks
are the actual “events” that interest us, so when this happens, we “wake up” the signal Mouse.position
to get the position of the click.
Signal.sampleOn
, (, ) , (, ).
, , show
main
.
http://elm-lang.org/try, , , .