2013-03-24 18:08:48 +00:00
|
|
|
|
|
|
|
module Graphics.Input where
|
|
|
|
|
2013-03-25 02:29:32 +00:00
|
|
|
import Signal (lift)
|
2013-03-25 02:19:30 +00:00
|
|
|
import Native.Graphics.Input as N
|
|
|
|
|
2013-03-25 02:29:32 +00:00
|
|
|
id x = x
|
|
|
|
|
2013-03-24 18:42:17 +00:00
|
|
|
buttons : a -> { button : a -> String -> Element, events : Signal a }
|
2013-03-24 18:08:48 +00:00
|
|
|
|
|
|
|
button : String -> (Element, Signal ())
|
|
|
|
button txt =
|
2013-03-25 02:19:30 +00:00
|
|
|
let pool = N.buttons ()
|
2013-03-24 18:08:48 +00:00
|
|
|
in (pool.button () txt, pool.events)
|
|
|
|
|
2013-03-24 18:42:17 +00:00
|
|
|
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 =
|
2013-03-25 02:19:30 +00:00
|
|
|
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
|
2013-03-24 18:42:17 +00:00
|
|
|
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-03-24 18:42:17 +00:00
|
|
|
|
2013-05-06 09:30:11 +00:00
|
|
|
fields : a -> { field : (FieldState -> a) -> String -> FieldState -> Element,
|
|
|
|
events : Signal a }
|
2013-03-24 18:42:17 +00:00
|
|
|
|
2013-05-06 09:30:11 +00:00
|
|
|
empty = { string="", start=0, end=0 }
|
|
|
|
|
2013-05-17 21:00:25 +00:00
|
|
|
field : String -> (Signal Element, Signal String)
|
2013-05-06 09:30:11 +00:00
|
|
|
field placeHolder =
|
|
|
|
let tfs = N.fields empty
|
2013-05-17 21:00:25 +00:00
|
|
|
in (lift (tfs.field id placeHolder) tfs.events, lift .string tfs.events)
|
2013-03-24 18:42:17 +00:00
|
|
|
|
2013-05-17 21:00:25 +00:00
|
|
|
password : String -> (Signal Element, Signal String)
|
2013-05-06 09:30:11 +00:00
|
|
|
password placeHolder =
|
|
|
|
let tfs = N.passwords empty
|
2013-05-17 21:00:25 +00:00
|
|
|
in (lift (tfs.field id placeHolder) tfs.events, lift .string tfs.events)
|
2013-04-01 07:35:18 +00:00
|
|
|
|
2013-05-17 21:00:25 +00:00
|
|
|
email : String -> (Signal Element, Signal String)
|
2013-05-06 09:30:11 +00:00
|
|
|
email placeHolder =
|
|
|
|
let tfs = N.emails empty
|
2013-05-17 21:00:25 +00:00
|
|
|
in (lift (tfs.field id placeHolder) tfs.events, lift .string tfs.events)
|
2013-03-24 18:42:17 +00:00
|
|
|
|
|
|
|
-- file?
|