Newer
Older
DTRAMServer / models / SimpleUI2.model
@Sakoda2269 Sakoda2269 on 19 Nov 2024 1 KB 不要なものを削除
init {
	screen := {
					"widgets": {
										"001": {
											"type": "button", 
											"text": "a", 
											"state": 0, 
											"x": 100, 
											"y": 100, 
											"width": 100, 
											"height": 40,
											"onPressed": {
												"method": "a"
											}
										}, 
										"002": {"type": "textInput", "text": "", "state": 0},
										"003": {
											"type": "button",
											"text": "change",
											"state": 0,
											"x": 50,
											"y": 50,
											"width": 100,
											"height": 40,
											"onPressed": {
												"method": "transition",
												"data": {
													"widgets": {
														"004": {"type": "label", "text": "hello", "state": 0, "x": 100, "y": 100}
													},
													"layout": true
												}
											}
										}
									}, 
					"layout": true
				}
}

native channel ScreenUpdate {
	in screen(curSc: Json, update(curSc, nextSc)) = nextSc
}

native channel ChangeScreen {
	out screen(curSc: Json, changeScreen(nextSc)) = nextSc
}

native channel SetLayout {
	in screen.layout(curLayout: Bool, setLayout(nextLayout)) = nextLayout
}

native channel SetVisible(wid: Str) {
	in screen.widgets.{wid}.visible(curVisible: Bool, setVisible(nextVisible)) = nextVisible
}

native channel SetText(wid: Str) {
	in screen.widgets.{wid}.text(curText: Str, setText(nextText)) = nextText
}

native channel MouseEvent(wid: Str) {
	out screen.widgets.{wid}.state(curState: Int, mouseEvent(nextState)) = nextState
}

native channel TextEvent(wid: Str) {
	out screen.widgets.{wid}.text(curText: Str, textEvent(nextText)) = nextText
}

channel AddTextInput {
	out screen.widgets(widgets: Map, addTextInput(wid: Str)) = insert(widgets, wid, {"type": "textInput", "text": "", "state": 0})
}

channel Test(wid: Str) {
	in screen.widgets.{wid}.state(curState: Int, test(nextState: Str, wid: Str)) = nextState
	out screen.widgets.{wid}.text(curText: Str, test(nextState: Str, wid: Str)) = if(wid == "001", "hello", curText)
}