Closed SalomonBrys closed 4 weeks ago
Describe the bug When showing an AwtWindow, after the window has closed, the MenuBar does not display anymore on Mac OS X.
Affected platforms
Versions
To Reproduce
Compile and run the following code:
import androidx.compose.foundation.layout.Column import androidx.compose.material.Text import androidx.compose.runtime.* import androidx.compose.ui.window.AwtWindow import androidx.compose.ui.window.MenuBar import androidx.compose.ui.window.singleWindowApplication import java.awt.FileDialog import java.awt.Frame import java.nio.file.Path import kotlin.io.path.Path import kotlin.io.path.absolutePathString @Composable fun FileLoadDialog( title: String, visible: Boolean = true, onResult: (result: Path?) -> Unit, ) { AwtWindow( visible = visible, create = { object : FileDialog(null as Frame?, title, LOAD) { override fun setVisible(value: Boolean) { super.setVisible(value) if (value) onResult(file?.let { Path(directory, file) }) } } }, dispose = FileDialog::dispose ) } fun main() = singleWindowApplication { var load: Boolean by remember { mutableStateOf(false) } var path: Path? by remember { mutableStateOf(null) } FileLoadDialog( title = "Load a file", visible = load, onResult = { path = it load = false } ) MenuBar { Menu("File") { Item("Load") { load = true } } Menu("Edit") { Item("Hello World!") {} } } Column { Text(if (load) "Loading..." else "Use File > Load to load a file") path?.let { Text(it.absolutePathString()) } } }
Note that if the application window loses focus, when the app regains focus, the menu is shown again.
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Describe the bug When showing an AwtWindow, after the window has closed, the MenuBar does not display anymore on Mac OS X.
Affected platforms
Versions
To Reproduce
Compile and run the following code:
Note that if the application window loses focus, when the app regains focus, the menu is shown again.