on master help sign in
Get Input library in shape to compile
d6acea8Evan Czaplicki
libraries/Graphics/Input.elm+8−1
@@ -2,8 +2,9 @@
2module Graphics.Input where
2module Graphics.Input where
3
3
4import Signal (lift,dropRepeats)
4import Signal (lift,dropRepeats)
5−import Native.Graphics.Input as N
5+import Native.Graphics.Input as Native
6import List
6import List
7+import Graphics.Element (Element)
7
8
8id x = x
9id x = x
9
10
@@ -17,6 +18,7 @@ id x = x
17-- The `a` value is sent to `events` whenever the button is pressed.
18-- The `a` value is sent to `events` whenever the button is pressed.
18buttons : a -> { events : Signal a,
19buttons : a -> { events : Signal a,
19 button : a -> String -> Element }
20 button : a -> String -> Element }
21+buttons = Native.buttons
20
22
21-- Create a button with a given label. The result is an `Element` and
23-- Create a button with a given label. The result is an `Element` and
22-- a signal of units. This signal triggers whenever the button is pressed.
24-- a signal of units. This signal triggers whenever the button is pressed.
@@ -36,6 +38,7 @@ button txt =
36-- The `a` value is sent to `events` whenever the button is pressed.
38-- The `a` value is sent to `events` whenever the button is pressed.
37customButtons : a -> { events : Signal a,
39customButtons : a -> { events : Signal a,
38 customButton : a -> Element -> Element -> Element -> Element }
40 customButton : a -> Element -> Element -> Element -> Element }
41+customButtons = Native.customButtons
39
42
40-- Create a button with custom states for up, hovering, and down
43-- Create a button with custom states for up, hovering, and down
41-- (given in that order). The result is an `Element` and
44-- (given in that order). The result is an `Element` and
@@ -57,6 +60,7 @@ customButton up hover down =
57-- lets you add an ID to distinguish between checkboxes.
60-- lets you add an ID to distinguish between checkboxes.
58checkboxes : a -> { events : Signal a,
61checkboxes : a -> { events : Signal a,
59 checkbox : (Bool -> a) -> Bool -> Element }
62 checkbox : (Bool -> a) -> Bool -> Element }
63+checkboxes = Native.checkboxes
60
64
61-- Create a checkbox with a given start state. Unlike `button`, this result
65-- Create a checkbox with a given start state. Unlike `button`, this result
62-- is a *signal* of elements. That is because a checkbox has state that
66-- is a *signal* of elements. That is because a checkbox has state that
@@ -69,6 +73,7 @@ checkbox b =
69
73
70hoverables : a -> { events : Signal a,
74hoverables : a -> { events : Signal a,
71 hoverable : (Bool -> a) -> Element -> Element }
75 hoverable : (Bool -> a) -> Element -> Element }
76+hoverables = Native.hoverables
72
77
73hoverable : Element -> (Element, Signal Bool)
78hoverable : Element -> (Element, Signal Bool)
74hoverable elem =
79hoverable elem =
@@ -98,6 +103,7 @@ type FieldState = { string:String, selectionStart:Int, selectionEnd:Int }
98-- lets you add an ID to distinguish between input fields.
103-- lets you add an ID to distinguish between input fields.
99fields : a -> { events : Signal a,
104fields : a -> { events : Signal a,
100 field : (FieldState -> a) -> String -> FieldState -> Element }
105 field : (FieldState -> a) -> String -> FieldState -> Element }
106+fields = Native.fields
101
107
102-- The empty field state:
108-- The empty field state:
103--
109--
@@ -138,6 +144,7 @@ email placeHolder =
138-- value. This lets you avoid manually mapping the string onto
144-- value. This lets you avoid manually mapping the string onto
139-- functions and values.
145-- functions and values.
140dropDown : [(String,a)] -> (Signal Element, Signal a)
146dropDown : [(String,a)] -> (Signal Element, Signal a)
147+dropDown = Native.dropDown
141
148
142-- Create a drop-down menu for selecting strings. The resulting
149-- Create a drop-down menu for selecting strings. The resulting
143-- signal of strings represents the string that is currently selected.
150-- signal of strings represents the string that is currently selected.