Safe Haskell | None |
---|
This module provides ''check box'' widgets and ''radio button'' widgets. In addition, this module provides a generalized ''multi-state'' check box type which allows you to set multiple states in the checkbox, each with its own character representation.
All of these types of widgets are toggled with the Spacebar and Enter keys.
- data CheckBox a
- type RadioGroup = IORef RadioGroupData
- newCheckbox :: Text -> IO (Widget (CheckBox Bool))
- setCheckboxUnchecked :: Widget (CheckBox Bool) -> IO ()
- setCheckboxChecked :: Widget (CheckBox Bool) -> IO ()
- toggleCheckbox :: Widget (CheckBox Bool) -> IO ()
- onCheckboxChange :: Widget (CheckBox a) -> (a -> IO ()) -> IO ()
- newMultiStateCheckbox :: Eq a => Text -> [(a, Char)] -> IO (Widget (CheckBox a))
- setCheckboxState :: Eq a => Widget (CheckBox a) -> a -> IO ()
- cycleCheckbox :: Eq a => Widget (CheckBox a) -> IO ()
- setStateChar :: Eq a => Widget (CheckBox a) -> a -> Char -> IO ()
- setBracketChars :: Widget (CheckBox a) -> Char -> Char -> IO ()
- getCheckboxLabel :: Widget (CheckBox a) -> IO Text
- getCheckboxState :: Widget (CheckBox a) -> IO a
- newRadioGroup :: IO RadioGroup
- onRadioChange :: RadioGroup -> (Widget (CheckBox Bool) -> IO ()) -> IO ()
- addToRadioGroup :: RadioGroup -> Widget (CheckBox Bool) -> IO ()
- getCurrentRadio :: RadioGroup -> IO (Maybe (Widget (CheckBox Bool)))
Documentation
type RadioGroup = IORef RadioGroupDataSource
Traditional binary-mode checkboxes
newCheckbox :: Text -> IO (Widget (CheckBox Bool))Source
Create a new checkbox with the specified text label.
Event handler registration
onCheckboxChange :: Widget (CheckBox a) -> (a -> IO ()) -> IO ()Source
Register a handler for a checkbox state change. The handler will be passed the new state value.
Generalized checkbox functions
:: Eq a | |
=> Text | The checkbox label. |
-> [(a, Char)] | The list of valid states that
the checkbox can be in, along
with the visual representation
( |
-> IO (Widget (CheckBox a)) |
Create a new multi-state checkbox.
setCheckboxState :: Eq a => Widget (CheckBox a) -> a -> IO ()Source
Set the state of a checkbox. May throw BadCheckboxState
.
cycleCheckbox :: Eq a => Widget (CheckBox a) -> IO ()Source
Cycle a checkbox's state to the next value in its state list.
setStateChar :: Eq a => Widget (CheckBox a) -> a -> Char -> IO ()Source
Set the visual representation for a state in a checkbox. May
throw BadStateArgument
.
setBracketChars :: Widget (CheckBox a) -> Char -> Char -> IO ()Source
Set the checkbox's bracketing characters for the left and right brackets around the state character.
getCheckboxState :: Widget (CheckBox a) -> IO aSource
Get a checkbox's current state value.
Radio groups
newRadioGroup :: IO RadioGroupSource
Create a new radio button group. This is used to guarantee exclusivity among the check boxes in the group so that they behave like radio buttons.
onRadioChange :: RadioGroup -> (Widget (CheckBox Bool) -> IO ()) -> IO ()Source
Register a handler to be notified when the currently-selected check box in a radio group changes.
addToRadioGroup :: RadioGroup -> Widget (CheckBox Bool) -> IO ()Source
Add a check box to a radio group. The check box's apperance will be changed so that it resembles a radio button.
getCurrentRadio :: RadioGroup -> IO (Maybe (Widget (CheckBox Bool)))Source
Get the currently-selected checkbox in a radio group, if any.