https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
g

Gordon

07/31/2022, 7:18 AM
How can i center AlertDialog in my application window? Currently I use custom dialog provider, to set the dialog to my desired look and fill.
Copy code
object CustomDialogProvider : AlertDialogProvider {
    @OptIn(ExperimentalComposeUiApi::class)
    @Composable
    override fun AlertDialog(
        onDismissRequest: () -> Unit,
        content: @Composable () -> Unit,
    ) {
        val painter = rememberVectorPainter(image = <http://Icons.Default.Engineering|Icons.Default.Engineering>)
        Dialog(
            title = "My Awesome Title",
            icon = painter,
            onCloseRequest = onDismissRequest,
            state = rememberDialogState(position = WindowPosition.Aligned(Alignment.Center), size = DpSize(400.dp, 200.dp)),
            undecorated = false,
            resizable = false,
            onKeyEvent = {
                if (it.key == Key.Escape) {
                    onDismissRequest()
                    true
                } else {
                    false
                }
            },
        ) {
            WindowDraggableArea {
                content()
            }
        }
    }
}
But the dialog shows centered in the Screen, and in multi-monitor, it's not even on the correct monitor. So, my app, runs on Monitor 1, and the dialog shows Centered on Monitor 0. And i want it Centered on Monitor 1, and not the entire screen, centered in application window.
43 Views