46 lines
1.5 KiB
Plaintext
46 lines
1.5 KiB
Plaintext
class TrackedPage: Page {
|
||
calls: Object
|
||
function moveToWindow(self: TrackedPage, window: Window): Page {
|
||
self.calls.increment()
|
||
return Page.moveToWindow(self, window)
|
||
}
|
||
function moveTab(self: TrackedPage, position: Number): Page {
|
||
self.calls.increment()
|
||
return Page.moveTab(self, position)
|
||
}
|
||
}
|
||
class Actions {
|
||
list: Column
|
||
function insert(self: Actions, event: Event): Unit {
|
||
self.list.insert(1, TextBlock("插入的新对象"))
|
||
}
|
||
}
|
||
calls = ui.state(0)
|
||
list = Column(0, 8, TextBlock("第一个子项"), TextBlock("最后一个子项"))
|
||
actions = Actions(list)
|
||
button = Button("在位置 1 插入 Block")
|
||
connection = button.on("click", actions.insert)
|
||
shared = Column(24, 16, TextBlock("拖动 Tab 重排、移入另一个窗口,或拖出独立窗口"), TextBlock("Page 方法调用次数"), ui.textOf(calls,"value"), button, list)
|
||
first = TrackedPage(calls)
|
||
first.title = "A · 共享内容"
|
||
first.render(shared)
|
||
second = TrackedPage(calls)
|
||
second.title = "B · 单独内容"
|
||
second.render(Column(24, 16, TextBlock("这是 B,Page 身份随 Tab 移动保留")))
|
||
third = TrackedPage(calls)
|
||
third.title = "C · 同一对象"
|
||
third.render(shared)
|
||
other = Window()
|
||
other.resize(720,520)
|
||
other.setTitle("Tab Target")
|
||
other.moveTo(1700,80)
|
||
target = TrackedPage(calls)
|
||
target.title = "目标窗口"
|
||
target.render(shared)
|
||
target.open(other)
|
||
first.activate()
|
||
ui.window().resize(800,600)
|
||
ui.window().setTitle("Tab Source")
|
||
ui.window().moveTo(50,80)
|
||
ui.window().focus()
|