on master help sign in
Add the basic proposal for an Input library.
26ddaf6evancz
libraries/Graphics/Input.elm+24−10
@@ -1,29 +1,43 @@
1
1
2module Graphics.Input where
2module Graphics.Input where
3
3
4−buttons : a -> { button : a -> String -> Element
4+buttons : a -> { button : a -> String -> Element, events : Signal a }
5− , events : Signal a
6− }
7
5
8button : String -> (Element, Signal ())
6button : String -> (Element, Signal ())
9button txt =
7button txt =
10 let pool = buttons ()
8 let pool = buttons ()
11 in (pool.button () txt, pool.events)
9 in (pool.button () txt, pool.events)
12
10
13−customButtons : a -> { button : a -> Element -> Element -> Element -> Element
11+customButtons : a -> { button : a -> Element -> Element -> Element -> Element,
14− , events : Signal a
12+ events : Signal a }
15− }
16
13
17customButton : Element -> Element -> Element -> (Element, Signal ())
14customButton : Element -> Element -> Element -> (Element, Signal ())
18customButton up hover down =
15customButton up hover down =
19 let pool = customButtons ()
16 let pool = customButtons ()
20 in (pool.button () up hover down, pool.events)
17 in (pool.button () up hover down, pool.events)
21
18
22−checkBoxes : a -> { box : (Bool -> a) -> Bool -> Element
19+checkBoxes : a -> { box : (Bool -> a) -> Bool -> Element, events : Signal a }
23− , events : Signal a
24− }
25
20
26checkBox : Bool -> (Signal Element, Signal Bool)
21checkBox : Bool -> (Signal Element, Signal Bool)
27checkBox b =
22checkBox b =
28 let cbs = checkBoxes b
23 let cbs = checkBoxes b
29− in (lift (cbs.box id) cbs.events, cbs.events)
24+ in (lift (cbs.box id) cbs.events, cbs.events)
25+
26+type TextState = {
27+ input : String,
28+ start : Int,
29+ end : Int
30+ }
31+
32+textFields : a -> { field : (TextState -> a) -> String -> TextState -> Element,
33+ events : Signal a }
34+
35+textField : String -> TextState -> (Signal Element, Signal TextState)
36+textField placeHolder textState =
37+ let tfs = textFields textState
38+ in (lift (tfs.field id placeHolder) tfs.events, tfs.events)
39+
40+password : String -> TextState -> (Signal Element, Signal TextState)
41+email : String -> TextState -> (Signal Element, Signal TextState)
42+
43+-- file?