In Elm, using Canvas rendering, you must use the signal Mouse.clicksand 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.clicksare the actual “events” that interest us, so when this happens, we “wake up” the signal Mouse.positionto get the position of the click.
Signal.sampleOn , (, ) , (, ).
, , show main.
http://elm-lang.org/try, , , .