What I want to do is set up fields which show detail when they're in focus, but summary when they're not. eg.
a). when it loses focus (gets blur?), I save the value in a (State?) Map and then change the value to a function of the old value (ie. the summary value)
b). when it gets focus - I replace the summary value with the old value that I saved in the Map
I cant' figure out how to do this, but I think I probably need a state monad and the UI monad. My try is:
renderField :: Map->Int->UI (Element, Map)
renderField vs ix = do
input <- UI.input
on UI.blur input $ \_ -> void $ do
fieldValue <- get value input
let newVs = insert ix fieldValue vs
return input # set UI.value (calcNewValue fieldValue)
on UI.focus input $ \_ -> void $ do
let savedValue = findWithDefault "" ix vs
return input # set UI.value savedValue
return (input, newVs)
but I can't get this map to work - because it needs to track all the calls.... I guess it should be State monad or something?
Thanks.
N