TestMultipleViewsOnSDS.icl 759 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
module TestMultipleViewsOnSDS
import iTasks

test :: Task (Maybe String)
test = withShared "" editTextWithDifferentViews

editTextWithDifferentViews model
	=           editInTextArea model
				-||-
				editAsListOfLines model
		>>*     [OnAction ActionQuit (Just o return o toMaybe)]

editInTextArea model
	=           updateSharedInformation ("Text","Edit text") [noteEditor] model
	>^*         [ OnAction (Action "Trim") (\txt -> Just (upd trim model))  
				]

editAsListOfLines model
	=   updateSharedInformation ("Lines","Edit lines") [listEditor] model

noteEditor = UpdateUsing id (const id) textArea
listEditor = UpdateAs (split "\n") (\_ l -> join "\n" l)

toMaybe (Value v _) =  (Just v)
toMaybe _   =  Nothing

Start world = startEngine test world