feat: dispatch managed events through capture and bubble subscriptions
Verify Tessera GUI / verify (push) Failing after 7m13s
Verify Tessera GUI / verify (push) Failing after 7m13s
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
| File | Purpose |
|
||||
| --- | --- |
|
||||
| [events.endor](events.endor) | Managed event subscriptions, source onEvent override and numbered capture/target/bubble steps from native input. |
|
||||
| [native-subclasses.endor](native-subclasses.endor) | Real native TextBlock/Button/Page source subclasses, inherited fields, method overrides and shared field bindings. |
|
||||
| [classes.endor](classes.endor) | Endor class fields, inheritance, overriding, a retained receiver and Event arguments; native keyboard input updates shared model properties. |
|
||||
| [managed-types.endor](managed-types.endor) | Callable managed Endor types, one shared counter, two bound displays and a language callback invoked from native Button input. |
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
class EventLog {
|
||||
count: Object
|
||||
captureStep: Number
|
||||
methodStep: Number
|
||||
targetStep: Number
|
||||
bubbleStep: Number
|
||||
phase: String
|
||||
function capture(self: EventLog, event: Event): Unit {
|
||||
self.count.increment()
|
||||
self.captureStep = self.count.value
|
||||
self.phase = event.phase
|
||||
}
|
||||
function target(self: EventLog, event: Event): Unit {
|
||||
self.count.increment()
|
||||
self.targetStep = self.count.value
|
||||
self.phase = event.phase
|
||||
}
|
||||
function bubble(self: EventLog, event: Event): Unit {
|
||||
self.count.increment()
|
||||
self.bubbleStep = self.count.value
|
||||
self.phase = event.phase
|
||||
}
|
||||
}
|
||||
class EventButton: Button {
|
||||
model: EventLog
|
||||
function onEvent(self: EventButton, event: Event): Unit {
|
||||
self.model.count.increment()
|
||||
self.model.methodStep = self.model.count.value
|
||||
self.model.phase = event.phase
|
||||
}
|
||||
}
|
||||
model = EventLog(ui.state(0), 0, 0, 0, 0, "等待点击")
|
||||
button = EventButton("捕获 → 对象方法 → 监听器 → 冒泡", model)
|
||||
root = Column(24, 16, TextBlock("同一对象系统中的事件分派", 2), button, ui.textOf(model.count, "value"), ui.textOf(model, "phase"))
|
||||
capture = root.on("click", model.capture, "capture")
|
||||
target = button.on("click", model.target)
|
||||
bubble = root.on("click", model.bubble)
|
||||
page = Page()
|
||||
page.render(root)
|
||||
Reference in New Issue
Block a user