class WindowActions { window: Window function compact(self: WindowActions, event: Event): Unit { self.window.resize(900, 600) } function wide(self: WindowActions, event: Event): Unit { self.window.resize(1120, 720) } } class WindowBand: RectBlock { function measure(self: WindowBand, mount: Mount, constraints: Constraints): MeasureResult { return MeasureResult(constraints.maxWidth, 32) } } window = ui.window() actions = WindowActions(window) band = WindowBand(80, 32, 0, "#237A45") compact = Button("紧凑窗口 900 × 600") wide = Button("宽窗口 1120 × 720") compactConnection = compact.on("click", actions.compact) wideConnection = wide.on("click", actions.wide) page = Page() page.render(Column(24, 16, TextBlock("代码与 GUI 操作同一个受管窗口对象"), band, compact, wide)) page.open(window) window.setTitle("Endor Window") window.resize(1120, 720)