-
-
Notifications
You must be signed in to change notification settings - Fork 77
/
Mouse.hs
26 lines (21 loc) · 871 Bytes
/
Mouse.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import Control.Monad (void)
import qualified Graphics.UI.Threepenny as UI
import Graphics.UI.Threepenny.Core
{-----------------------------------------------------------------------------
Main
------------------------------------------------------------------------------}
main :: IO ()
main = startGUI defaultConfig setup
setup :: Window -> UI ()
setup w = do
return w # set title "Mouse"
out <- UI.span # set text "Coordinates: "
wrap <- UI.div #. "wrap"
# set style [("width","300px"),("height","300px"),("border","solid black 1px")]
# set (attr "tabindex") "1" -- allow key presses
#+ [element out]
getBody w #+ [element wrap]
on UI.mousemove wrap $ \xy ->
element out # set text ("Coordinates: " ++ show xy)
on UI.keydown wrap $ \c ->
element out # set text ("Keycode: " ++ show c)