Scoop API

scoop:scoop.ui:0.1.0

platform/desktop/application.scoop

Selected production source · platform/desktop/application.scoop

1package scoop.ui
3import scoop.graphics.text.FontCollection
4import scoop.window.*
6/** A single-window entry point with the same explicit root ownership as UiHost.use. */
7public fun <C: Component> runUiApplication(
8 title: String,
9 create: (ComponentScope) -> C,
10 fonts: FontCollection? = None,
11 preferences: UiPreferences = uiPreferences()
12) {
13 val application =
14 Application(applicationOptions { this.lastWindowPolicy = LastWindowPolicy.Exit })
15 UiHost(onRootError = { _, error -> throw error }) {
16 host,
17 active,
18 event -> when (event) {
19 case Resumed -> host.attach(
20 active.createWindow(windowAttributes { this.title = title }),
21 create,
22 fonts,
23 preferences
24 )
25 case Window(val id, WindowEvent.CloseRequested) -> active.requestExit()
26 else -> {}
27 }
28 }.use { host -> application.run(host) }