Data update
This commit is contained in:
parent
157b70a810
commit
8e4e15fa56
78 changed files with 2016 additions and 222 deletions
20
Task/Mouse-position/Haskell/mouse-position.hs
Normal file
20
Task/Mouse-position/Haskell/mouse-position.hs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import qualified Graphics.UI.Threepenny as UI
|
||||
import Graphics.UI.Threepenny.Core
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
startGUI defaultConfig setup -- Start the Threepenny server
|
||||
|
||||
setup :: Window -> UI ()
|
||||
setup window = do
|
||||
-- Set the window title
|
||||
pure window # set UI.title "Cursor Position Example"
|
||||
|
||||
-- Create a display area
|
||||
displayArea <- UI.div # set UI.style [("width", "100%"), ("height", "100vh"), ("background", "#f0f0f0")]
|
||||
getBody window #+ [element displayArea]
|
||||
|
||||
-- Event listener for mouse movements
|
||||
on UI.mousemove displayArea $ \(x, y) -> do
|
||||
-- This prints in terminal where threepenny-gui server was started, NOT in browser console
|
||||
liftIO $ putStrLn $ "Mouse cursor position relative to window: (" ++ show x ++ ", " ++ show y ++ ")"
|
||||
Loading…
Add table
Add a link
Reference in a new issue