rob42
08/21/2024, 4:46 PMrob42
08/21/2024, 4:49 PMwindow.toFront()
), but I'd like to achieve a design where the window isn't responsible for bringing itself to the frontAlexander Maryanovsky
08/21/2024, 5:51 PMwindow.toFront()
is the right wayAlexander Maryanovsky
08/21/2024, 5:52 PMtoFront()
on it when you needAlexander Maryanovsky
08/21/2024, 5:53 PM/**
* Shows the settings window on the given pane.
*/
fun showSettingsWindow(pane: SettingsPane = SettingsPane.Default) {
when (val state = settingsWindowState) {
is SettingsWindowState.Closed -> settingsWindowState = SettingsWindowState.Open(pane)
is SettingsWindowState.Open -> {
state.pane = pane
state.window?.toFront()
}
}
}
/**
* Closes the settings window.
*/
fun closeSettingsWindow() {
settingsWindowState = SettingsWindowState.Closed
}
Alexander Maryanovsky
08/21/2024, 5:55 PMSettingsWindow
I have
Window(...) {
LaunchedEffect(state, window) {
state.window = window
}
}
rob42
08/22/2024, 9:46 AMWindow
composable, where things for the parent to use are passed in (e.g. rememberWindowState
).
I ended up making a minimal BringToFrontRequester
which can be passed to the window, which then binds to it. Much like a FocusRequester.Alexander Maryanovsky
08/22/2024, 9:50 AMWindowManager
object responsible for all the windows in the app.Alexander Maryanovsky
08/22/2024, 9:53 AMwindow
property to it.rob42
08/22/2024, 9:59 AM