on master help sign in
Add examples for all exported functions
commita35f47fac97fa141742906d0ea7d0c137c613f76 authorEvan Czaplicki <info@elm-lang.org> dateTue 18 Feb 2014, 14:21 (13 years ago) parent6a2d21f
1 file changed+27−2
libraries/Graphics/Input.elm+27−2
libraries/Graphics/Input.elm+27−2
@@ -33,8 +33,6 @@ import Signal (Signal)
3333import Graphics.Element (Element)
3434import Native.Graphics.Input
3535
36−data Handle a = Handle
37−
3836{-| This is the key abstraction of this library. An `Input` is a record
3937of two fields:
4038
@@ -45,6 +43,8 @@ This will make more sense as you see more examples.
4543-}
4644type Input a = { signal : Signal a, handle : Handle a }
4745
46+data Handle a = Handle
47+
4848{-| Create a new `Input`. You just give the initial value for the
4949input&rsquo;s `signal`.
5050
@@ -78,9 +78,34 @@ users presses "2", `keys.signal` will update to `(Number 2)`.
7878button : Handle a -> a -> String -> Element
7979button = Native.Graphics.Input.button
8080
81+{-| Same as `button` but lets you customize buttons to look however you want.
82+
83+ click : Input ()
84+ click = input ()
85+
86+ prettyButton : Element
87+ prettyButton =
88+ customButton click.handle
89+ (image 100 40 "/button_up.jpg")
90+ (image 100 40 "/button_hover.jpg")
91+ (image 100 40 "/button_down.jpg")
92+-}
8193customButton : Handle a -> a -> Element -> Element -> Element -> Element
8294customButton = Native.Graphics.Input.customButton
8395
96+{-| Create a checkbox. The following example creates three synced checkboxes:
97+
98+ check : Input Bool
99+ check = input False
100+
101+ boxes : Bool -> Element
102+ boxes checked =
103+ let box = container 40 40 middle (checkbox check.handle id checked)
104+ in flow right [ box, box, box ]
105+
106+ main : Signal Element
107+ main = boxes <~ check.signal
108+-}
84109checkbox : Handle a -> (Bool -> a) -> Bool -> Element
85110checkbox = Native.Graphics.Input.checkbox
86111