mouse listener in Haskell
-
08-12-2019 - |
Question
I'm trying to make a program in Haskell using opengl that draws a circle when the mouse is clicked, where it is clicked. The trouble is, I can't find anything that can show me how to make a mouse listener. Does anybody know any good tutorial sites?
Solution
If you are using GLUT, you'll find what you need in Graphics.UI.GLUT.Callbacks.Window
, specifically, keyboardMouseCallback
. Note that mouse buttons are treated like keyboard keys:
myKeyboardMouseCallback key keyState modifiers position =
case (key, keyState) of
(MouseButton LeftButton, Down) -> do
{- draw circle @ position ... -}
_ -> return () -- ignore other buttons
attachMyKeyboardMouseCallback = keyboardMouseCallback $= Just myKeyboardMouseCallback
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow