Mouse buttons and wheels

36 views
Skip to first unread message

Ken Rose

unread,
Feb 13, 2016, 9:01:25 PM2/13/16
to Elm Discuss
Attached is a patch to allow Elm programs to distinguish among the three mouse buttons and to read the mouse wheels.  It leaves the current mouse interface unchanged, but add calls to report specific button presses and to report wheel motions.  The Javascript mouse interface defines three wheels, and this reports a triple of all three.  The middle one is the normal one we're all used to.  The new interface is:

module Mouse
    ( position, x, y
    , isDown, clicks
    , isLDown
    , isCDown
    , isRDown
    , wheel
    )

Mouse.isLDown, Mouse.isCDown, and Mouse.isRDown report status for the left, center, and right buttons, respectively.  Mouse.wheel reports a triplet of type (Int,Int,Int) for the three wheel components (X_wheel, Y_wheel, Z_wheel).  As I mentioned, the normal wheel/button is the Y wheel.

Someone with full familiarity with the cross-browser issues should review this, though it works for me, in the cases I've tried.

I'm amazed this hasn't been done before.

 - ken
elm-mouse.patch
Reply all
Reply to author
Forward
0 new messages