elm/libraries/Graphics/Input.elm

51 lines
1.6 KiB
Elm
Raw Normal View History

2013-03-24 18:08:48 +00:00
module Graphics.Input where
2013-03-25 02:29:32 +00:00
import Signal (lift)
import Native.Graphics.Input as N
2013-03-25 02:29:32 +00:00
id x = x
buttons : a -> { button : a -> String -> Element, events : Signal a }
2013-03-24 18:08:48 +00:00
button : String -> (Element, Signal ())
button txt =
let pool = N.buttons ()
2013-03-24 18:08:48 +00:00
in (pool.button () txt, pool.events)
customButtons : a -> { button : a -> Element -> Element -> Element -> Element,
events : Signal a }
2013-03-24 18:08:48 +00:00
customButton : Element -> Element -> Element -> (Element, Signal ())
customButton up hover down =
let pool = N.customButtons ()
2013-03-24 18:08:48 +00:00
in (pool.button () up hover down, pool.events)
checkBoxes : a -> { box : (Bool -> a) -> Bool -> Element, events : Signal a }
2013-03-24 18:08:48 +00:00
checkBox : Bool -> (Signal Element, Signal Bool)
checkBox b =
let cbs = N.checkBoxes b
in (lift (cbs.box id) cbs.events, cbs.events)
2013-05-05 01:58:10 +00:00
type TextState = { text:String, start:Int, end:Int }
textFields : a -> { field : (TextState -> a) -> String -> TextState -> Element,
events : Signal a }
text : String -> TextState -> (Signal Element, Signal TextState)
text placeHolder textState =
let tfs = N.textFields textState
in (lift (tfs.field id placeHolder) tfs.events, tfs.events)
password : String -> TextState -> (Signal Element, Signal TextState)
password placeHolder textState =
let tfs = N.passwords textState
in (lift (tfs.field id placeHolder) tfs.events, tfs.events)
email : String -> TextState -> (Signal Element, Signal TextState)
email placeHolder textState =
let tfs = N.emails textState
in (lift (tfs.field id placeHolder) tfs.events, tfs.events)
-- file?