Bind managed Block properties with read-only dependency tracking
Verify Tessera GUI / verify (push) Failing after 7m31s
Verify Tessera GUI / verify (push) Failing after 7m31s
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
class Model {
|
||||
width: Number
|
||||
color: String
|
||||
label: String
|
||||
function getWidth(self: Model): Number { return self.width }
|
||||
function getColor(self: Model): String { return self.color }
|
||||
function getLabel(self: Model): String { return self.label }
|
||||
function expand(self: Model, event: Event): Unit {
|
||||
self.width = 260
|
||||
self.color = "#237A45"
|
||||
self.label = "绑定已更新"
|
||||
}
|
||||
}
|
||||
model = Model(120, "#526AC7", "点击更新共享对象")
|
||||
rect = RectBlock(120, 40, 8, "#526AC7")
|
||||
label = TextBlock("初始化")
|
||||
widthBinding = rect.bind("width", model.getWidth)
|
||||
colorBinding = rect.bind("color", model.getColor)
|
||||
labelBinding = label.bind("text", model.getLabel)
|
||||
button = Button("更新宽度、颜色和文字")
|
||||
clickConnection = button.on("click", model.expand)
|
||||
root = Column(24, 16, label, rect, button)
|
||||
page = Page()
|
||||
page.title = "通用属性绑定"
|
||||
page.render(root)
|
||||
second = Page()
|
||||
second.title = "同一组 Block"
|
||||
second.render(root)
|
||||
page.activate()
|
||||
Reference in New Issue
Block a user