elm/libraries/Graphics/Input.elm

53 lines
1.5 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)
2013-05-06 09:30:11 +00:00
checkboxes : a -> { box : (Bool -> a) -> Bool -> Element, events : Signal a }
2013-03-24 18:08:48 +00:00
2013-05-06 09:30:11 +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-06 09:30:11 +00:00
type FieldState = { string:String, start:Int, end:Int }
2013-05-06 09:30:11 +00:00
fields : a -> { field : (FieldState -> a) -> String -> FieldState -> Element,
events : Signal a }
2013-05-06 09:30:11 +00:00
empty = { string="", start=0, end=0 }
field : String -> (Signal Element, Signal String)
2013-05-06 09:30:11 +00:00
field placeHolder =
let tfs = N.fields empty
in (lift (tfs.field id placeHolder) tfs.events, lift .string tfs.events)
password : String -> (Signal Element, Signal String)
2013-05-06 09:30:11 +00:00
password placeHolder =
let tfs = N.passwords empty
in (lift (tfs.field id placeHolder) tfs.events, lift .string tfs.events)
email : String -> (Signal Element, Signal String)
2013-05-06 09:30:11 +00:00
email placeHolder =
let tfs = N.emails empty
in (lift (tfs.field id placeHolder) tfs.events, lift .string tfs.events)
-- file?