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-03-24 18:42:17 +00:00
|
|
|
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 =
|
2013-03-25 02:19:30 +00:00
|
|
|
let cbs = N.checkBoxes b
|
2013-03-24 18:42:17 +00:00
|
|
|
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 }
|
2013-03-24 18:42:17 +00:00
|
|
|
|
|
|
|
textFields : a -> { field : (TextState -> a) -> String -> TextState -> Element,
|
|
|
|
events : Signal a }
|
|
|
|
|
2013-04-01 07:35:18 +00:00
|
|
|
text : String -> TextState -> (Signal Element, Signal TextState)
|
|
|
|
text placeHolder textState =
|
2013-03-25 02:19:30 +00:00
|
|
|
let tfs = N.textFields textState
|
2013-03-24 18:42:17 +00:00
|
|
|
in (lift (tfs.field id placeHolder) tfs.events, tfs.events)
|
|
|
|
|
|
|
|
password : String -> TextState -> (Signal Element, Signal TextState)
|
2013-04-01 07:35:18 +00:00
|
|
|
password placeHolder textState =
|
|
|
|
let tfs = N.passwords textState
|
|
|
|
in (lift (tfs.field id placeHolder) tfs.events, tfs.events)
|
|
|
|
|
2013-03-24 18:42:17 +00:00
|
|
|
email : String -> TextState -> (Signal Element, Signal TextState)
|
2013-04-01 07:35:18 +00:00
|
|
|
email placeHolder textState =
|
|
|
|
let tfs = N.emails textState
|
|
|
|
in (lift (tfs.field id placeHolder) tfs.events, tfs.events)
|
2013-03-24 18:42:17 +00:00
|
|
|
|
|
|
|
-- file?
|