| | init { |
---|
| | screen := { |
---|
| | "widgets": { |
---|
| | "001": {"type": "button", "text": "a", "state": 0}, |
---|
| | "002": {"type": "textInput", "text": "", "state": 0} |
---|
| | }, |
---|
| | "layout": true |
---|
| | } |
---|
| | variables := { |
---|
| | "a": { |
---|
| | "from": "001", |
---|
| | "to": "002" |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | native channel ScreenUpdate { |
---|
| | in screen(curSc: Json, update(curSc, nextSc)) = nextSc |
---|
| |
---|
| | native channel TextEvent(wid: Str) { |
---|
| | out screen.widgets.{wid}.text(curText: Str, textEvent(nextText)) = nextText |
---|
| | } |
---|
| | |
---|
| | channel AddButton { |
---|
| | out screen.widgets(widgets: Map, addButton(wid: Str, text: Str)) = insert(widgets, wid, {"type": "button", "text": text, "state": 0}) |
---|
| | } |
---|
| | |
---|
| | channel AddTextInput { |
---|
| | out screen.widgets(widgets: Map, addTextInput(wid: Str)) = insert(widgets, wid, {"type": "textInput", "text": "", "state": 0}) |
---|
| | } |
---|
| | |
---|
| | channel ChangeText(wid: Str) { |
---|
| | ref variables.a.from(from, updateText(from, to, newText)) |
---|
| | ref variables.a.to(to, updateText(from, to, nexText)) |
---|
| | in screen.widgets.{wid}.text(curText: Str, updateText(from, to, nexText)) = curText |
---|
| | out screen.widgets.{to}.text(curText: Str, updateText(from, to, nexText)) = if(wid == from, nextText, curText) |
---|
| | } |
---|
| | |
---|
| | |
|