24 lines
960 B
Plaintext
24 lines
960 B
Plaintext
class CircleTarget: RectBlock {
|
|
hits: Object
|
|
function hitTest(self: CircleTarget, mount: Mount, point: Point): Bool {
|
|
return point.inCircle(40, 40, 40)
|
|
}
|
|
function paint(self: CircleTarget, mount: Mount, geometry: Bounds): DisplayList {
|
|
drawing = RectBlock.paint(self, mount, geometry)
|
|
drawing.commands.at(0).width = 80
|
|
drawing.commands.at(0).radius = 40
|
|
return drawing
|
|
}
|
|
function onEvent(self: CircleTarget, event: Event): Unit {
|
|
self.hits.increment()
|
|
event.stopPropagation()
|
|
}
|
|
}
|
|
hits = ui.state(0)
|
|
background = ui.state(0)
|
|
circle = CircleTarget(160, 80, 0, "#237A45", hits)
|
|
root = Column(24, 16, circle, TextBlock("点击圆内计入圆;透明右半区域交给父容器"), TextBlock("圆内点击"), ui.textOf(hits, "value"), TextBlock("父容器点击"), ui.textOf(background, "value"))
|
|
connection = root.on("click", background.increment)
|
|
page = Page()
|
|
page.render(root)
|