Skip to content

Instantly share code, notes, and snippets.

@imalsogreg
Created December 15, 2015 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imalsogreg/23bb7b8e02ccef36e473 to your computer and use it in GitHub Desktop.
Save imalsogreg/23bb7b8e02ccef36e473 to your computer and use it in GitHub Desktop.
Use of Reflex.Dom.Contrib.Widgets.ButtonGroup
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RecursiveDo #-}
module Main where
import Data.Bool
import Data.Char
import Data.Default
import qualified Data.Map as Map
import Data.Monoid
import Reflex.Dom
import Reflex.Dom.Contrib.Widgets.Common
import Reflex.Dom.Contrib.Widgets.ButtonGroup
main :: IO ()
main = mainWidget $ mdo
res' <- radioGroup (constDyn "g") (constDyn [(100 :: Int, "Test"), (300, "Test2"), (200, "Hello")])
(WidgetConfig {_widgetConfig_initialValue = Nothing
,_widgetConfig_setValue = never
,_widgetConfig_attributes = constDyn mempty})
display (_hwidget_value res')
res'' <- bootstrapButtonGroup (constDyn [(100,"Test"), (200,"Test2"), (300,"Hello")])
(WidgetConfig { _widgetConfig_initialValue = Nothing
, _widgetConfig_setValue = change res'
, _widgetConfig_attributes = constDyn mempty})
display (value res'')
lastRes'' <- holdDyn Nothing (traceEvent "TEST" (change res''))
display lastRes''
el "br" $ return ()
display (_hwidget_hasFocus res'')
el "br" $ return ()
display =<< holdDyn "" (fmap show (leftmost [_hwidget_keyup res''
, _hwidget_keydown res''
, _hwidget_keypress res'']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment