Go to the first, previous, next, last section, table of contents.

Toggle example


mkToggle :: ToggleResources -> Component (Toggle Bool, DisplayHandle)

main =
 wopen [] (mkToggle []) >>
 return ()

Basic toggle

The first argument to mkToggle is a list of attributes to use other than the defaults for the Toggle instance. One of the attributes are the Picture labels to use for the `on' and `off' states of the Toggle. As you can see above, the default for the labels is not picture label at all, but the labels can be changed dynamically:


setToggleLabel :: Toggle a -> Bool -> Picture -> IO ()

main =
 wopen [] (mkToggle [])                >>= \ (tog,_) ->
 setToggleLabel tog True (text "On")   >> 
 setToggleLabel tog False (text "Off") >> 
 return ()

Basic toggle On Basic toggle Off


Go to the first, previous, next, last section, table of contents.