Closed haikalpribadi closed 2 years ago
You can use Dialog
as described here. Dialog will block the parent window
Thanks, @igordmn - I've actually tried that before, and I've tried it again just now, following your link. It doesn't work and it's worse that than Window
as I can't set alwaysOnTop = true
. When the Dialog
opens, I can click on the parent, and the dialog gets hidden behind the parent. At least with Window
, I can set alwaysOnTop = true
so the child window never gets hidden.
Is this a bug with androidx.compose.ui.windowDialog
? We're not expecting it to behave this way, right?
What JDK and OS do you use? And what version of Compose?
Last time I checked, the parent window blocks when we open Dialog on all OS'es.
This is on Windows:
https://user-images.githubusercontent.com/5963351/144047412-4d09a6c1-50fc-453f-8dc0-e1a31f6f5af2.mp4
I'm on MacOS 12.0.1 Monterey, Java 11, and Jetpack Compose 1.0.0 RC3.
Here's the constructor that I use:
androidx.compose.ui.window.Dialog(
title = Label.CONNECT_TO_TYPEDB,
onCloseRequest = { State.connection.showWindow = false },
state = rememberDialogState(
position = WindowPosition.Aligned(Alignment.Center),
size = DpSize(WINDOW_WIDTH, WINDOW_HEIGHT)
)
) { ... }
And here's a recording of the behaviour:
https://user-images.githubusercontent.com/567679/144094120-a671b294-c940-403f-8f51-76794e7a1b2d.mov
Looks like a bug? 🤔
Where Dialog
is used? It should be inside Window
, so it will know which window should be blocked
Ah! Amazing! that was the problem indeed! I was calling my dialogs outside the parent window. 🤦🏽♂️ Thanks for point this out. I've solved my problem now and will close this issue. Thanks, @igordmn !
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Hi 👋🏽 I need to open a popup/modal window while a parent window open, and I've found
androidx.compose.ui.window.Window
to be the most appropriate library that suits our requirement. I have setalwaysOnTop = true
, however, I can't stop the parent window receiving user interaction. Note that I can't make this work withandroidx.compose.ui.window.Popup
orandroidx.compose.material.AlertDialog
either -- they both allow the parent window to be interacted by the user. Is there a way to make a popup/modal window that also prohibits the user from clicking/interacting with the parent window until the modal window is closed? Particularly, is can we make it work withWindow
?