Igor Demin
06/22/2021, 9:08 AMWindow(onCloseRequest=)
is required parameter now
2. WindowState.isMaximized
, WindowState.isFullscreen
are merged to WindowState.placement { Floating, Maximized, Fullscreen }
3. WindowPosition
is sealed class { PlatformDefault, Aligned, Absolute }
, initialAlignment
removed from Window/DialogIgor Demin
06/22/2021, 9:09 AMWe have only one case where omitting that parameter is useful - a single-window application. In the other cases if we omit this parameter - we will have state desynchronization: is required parameter nowWindow(onCloseRequest=)
var isSecondWindowOpen = ...
if (isSecondWindowOpen) {
// when we close the window, we change internal isOpen state, but don't change isSecondWindowOpen state. And because we don't change isSecondWindowOpen, we can't reopen the window
Window {
}
}
For the single-window case we created a special function exitApplication
, that closes all windows/trays and cancels `LaunchedEffect`'s inside application
block. An alternative to exitApplication
- is to use your own state:
fun main() = application {
var isApplicationOpen by remember { mutableStateOf(true) }
if (isApplicationOpen) {
Window(onCloseRequest = { isApplicationOpen = false }) { ... }
Tray(...)
LaunchedEffect(Unit) { ... }
}
}