28 lines
1005 B
Plaintext
28 lines
1005 B
Plaintext
class Product {
|
|
name: String
|
|
color: String
|
|
function label(self: Product): String { return self.name }
|
|
function shade(self: Product): String { return self.color }
|
|
function update(self: Product, event: Event): Unit {
|
|
self.name = "原业务对象已更新"
|
|
self.color = "#237A45"
|
|
}
|
|
function present(self: Product, window: Window): Block {
|
|
title = TextBlock(self.name)
|
|
swatch = RectBlock(180,48,8,self.color)
|
|
titleBinding = title.bind("text",self.label)
|
|
colorBinding = swatch.bind("color",self.shade)
|
|
button = Button("调用业务对象方法")
|
|
connection = button.on("click",self.update)
|
|
result = Column(24,16,title,swatch,button)
|
|
result.source = self
|
|
result.contextWindow = window.id()
|
|
return result
|
|
}
|
|
}
|
|
ui.implement(Product,Presentable)
|
|
product = Product("普通对象的显式展示能力", "#526AC7")
|
|
view = ui.present(product)
|
|
page = ui.open(view)
|
|
page.title = "Presentable"
|