Created
July 16, 2012 12:39
-
-
Save RudolfVonKrugstein/3122464 to your computer and use it in GitHub Desktop.
UHC imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreign import js "%1.keyCode" | |
keyCode :: JSKeyEvent -> IO Int | |
foreign import js "window.addEventListener('keydown',%1,true)" | |
jsSetOnKeyDown :: FunPtr (JSKeyEvent -> IO ()) -> IO () | |
setOnKeyDown (Int -> IO ()) -> IO () | |
setOnKeyDown fp = dp | |
cb <- mkKeyEventCb fp' | |
jsSetOnKeyDown cb | |
where | |
fp' event = keyCode event >>= fp | |
foreign import js "window.addEventListener('keyup',%1,true)" | |
jsSetOnKeyUp :: FunPtr (JSKeyEvent -> IO ()) -> IO () | |
setOnKeyDown (Int -> IO ()) -> IO () | |
setOnKeyDown fp = dp | |
cb <- mkKeyEventCb fp' | |
jsSetOnKeyUp cb | |
where | |
fp' event = keyCode event >>= fp | |
foreign import js "window.addEventListener('load', %1, 'false')" | |
jsSetOnLoad :: FunPtr (IO ()) -> IO () | |
setOnLoad :: IO () -> IO () | |
setOnLoad fp = mkCb fp >>= setOnLoad_ | |
foreign import js "setInterval(%1,%2)" | |
jsSetInterval :: FunPtr (IO ()) -> Int -> IO () | |
setInterval :: IO () -> Int -> IO () | |
setInterval fp time = mkCb fp >>= (jsSetInterval time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment