module Language.Nomyx.Inputs (
InputForm(..),
onInputRadio, onInputRadio_, onInputRadioOnce,
onInputText, onInputText_, onInputTextOnce,
onInputCheckbox, onInputCheckbox_, onInputCheckboxOnce,
onInputButton, onInputButton_, onInputButtonOnce,
onInputTextarea, onInputTextarea_, onInputTextareaOnce,
baseInputRadio, baseInputText, baseInputCheckbox, baseInputButton, baseInputTextarea,
inputRadio, inputText, inputCheckbox, inputButton, inputTextarea
) where
import Language.Nomyx.Expression
import Language.Nomyx.Events
import Data.Typeable
import Control.Applicative
onInputRadio :: (Typeable a, Eq a, Show a) => String -> [a] -> (EventNumber -> a -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputRadio title choices handler pn = onEvent (inputRadioHead pn title choices) (\(en, a) -> handler en a)
onInputRadio_ :: (Typeable a, Eq a, Show a) => String -> [a] -> (a -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputRadio_ title choices handler pn = onEvent_ (inputRadioHead pn title choices) handler
onInputRadioOnce :: (Typeable a, Eq a, Show a) => String -> [a] -> (a -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputRadioOnce title choices handler pn = onEventOnce (inputRadioHead pn title choices) handler
inputRadioHead :: (Eq c, Show c, Typeable c) => PlayerNumber -> String -> [c] -> Event c
inputRadioHead pn title choices = inputRadio pn title choices (head choices)
inputRadio :: (Eq c, Show c, Typeable c) => PlayerNumber -> String -> [c] -> c -> Event c
inputRadio pn title cs _ = baseEvent $ baseInputRadio pn title (zip cs (show <$> cs))
baseInputRadio :: (Eq c, Show c, Typeable c) => PlayerNumber -> String -> [(c, String)] -> Field c
baseInputRadio pn title cs = baseInputEvent pn title (Radio cs)
onInputText :: String -> (EventNumber -> String -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputText title handler pn = onEvent (inputText pn title) (\(en, a) -> handler en a)
onInputText_ :: String -> (String -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputText_ title handler pn = onEvent_ (inputText pn title) handler
onInputTextOnce :: String -> (String -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputTextOnce title handler pn = onEventOnce (inputText pn title) handler
inputText :: PlayerNumber -> String -> Event String
inputText pn title = baseEvent $ baseInputText pn title
baseInputText :: PlayerNumber -> String -> Field String
baseInputText pn title = baseInputEvent pn title Text
onInputCheckbox :: (Typeable a, Eq a, Show a) => String -> [(a, String)] -> (EventNumber -> [a] -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputCheckbox title choices handler pn = onEvent (inputCheckbox pn title choices) (\(en, a) -> handler en a)
onInputCheckbox_ :: (Typeable a, Eq a, Show a) => String -> [(a, String)] -> ([a] -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputCheckbox_ title choices handler pn = onEvent_ (inputCheckbox pn title choices) handler
onInputCheckboxOnce :: (Typeable a, Eq a, Show a) => String -> [(a, String)] -> ([a] -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputCheckboxOnce title choices handler pn = onEventOnce (inputCheckbox pn title choices) handler
inputCheckbox :: (Eq c, Show c, Typeable c) => PlayerNumber -> String -> [(c, String)] -> Event [c]
inputCheckbox pn title cs = baseEvent $ baseInputCheckbox pn title cs
baseInputCheckbox :: (Eq c, Show c, Typeable c) => PlayerNumber -> String -> [(c, String)] -> Field [c]
baseInputCheckbox pn title cs = baseInputEvent pn title (Checkbox cs)
onInputButton :: String -> (EventNumber -> () -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputButton title handler pn = onEvent (inputButton pn title) (\(en, ()) -> handler en ())
onInputButton_ :: String -> (() -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputButton_ title handler pn = onEvent_ (inputButton pn title) handler
onInputButtonOnce :: String -> (() -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputButtonOnce title handler pn = onEventOnce (inputButton pn title) handler
inputButton :: PlayerNumber -> String -> Event ()
inputButton pn title = baseEvent $ baseInputButton pn title
baseInputButton :: PlayerNumber -> String -> Field ()
baseInputButton pn title = baseInputEvent pn title Button
onInputTextarea :: String -> (EventNumber -> String -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputTextarea title handler pn = onEvent (inputTextarea pn title) (\(en, a) -> handler en a)
onInputTextarea_ :: String -> (String -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputTextarea_ title handler pn = onEvent_ (inputTextarea pn title) handler
onInputTextareaOnce :: String -> (String -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
onInputTextareaOnce title handler pn = onEventOnce (inputTextarea pn title) handler
inputTextarea :: PlayerNumber -> String -> Event String
inputTextarea pn title = baseEvent $ baseInputTextarea pn title
baseInputTextarea :: PlayerNumber -> String -> Field String
baseInputTextarea pn title = baseInputEvent pn title TextArea