Kirill Grouchnikov
12/09/2021, 3:54 PMOnGloballyPositionedModifier to determine the position of this combobox so that I can place the popup / dropdown window accordingly. But in this mode where the window decorations come from the system, both coordinates.localToRoot(Offset.Zero) and coordinates.localToWindow(Offset.Zero) give me the same value of Offset(110.0, 99.0). Shouldn't localToWindow account for the height of the title bar?Kirill Grouchnikov
12/09/2021, 3:58 PMKirill Grouchnikov
12/09/2021, 3:58 PMprivate class MyLocator :
OnGloballyPositionedModifier {
override fun onGloballyPositioned(coordinates: LayoutCoordinates) {
println("local to root ${coordinates.localToRoot(Offset.Zero)}")
println("local to window ${coordinates.localToWindow(Offset.Zero)}")
}
}
@Composable
private fun Modifier.myLocator() = this.then(
MyLocator()
)
fun main() = application {
val state = rememberWindowState(
placement = WindowPlacement.Floating,
position = WindowPosition.Aligned(Alignment.Center),
size = DpSize(220.dp, 150.dp)
)
Window(
title = "Aurora Demo",
state = state,
undecorated = false,
onCloseRequest = ::exitApplication
) {
Row(
modifier = Modifier.fillMaxSize(),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
) {
Box(modifier = Modifier.size(50.dp).background(Color.Red).myLocator())
}
}
}olonho
12/09/2021, 4:31 PMKirill Grouchnikov
12/09/2021, 4:37 PMKirill Grouchnikov
12/09/2021, 5:00 PMComposeWindow.getRootPane().getLocationOnScreen() instead of ComposeWindow.getLocationOnScreen()Igor Demin
01/10/2022, 9:51 AM