compose-multiplatform
compose-multiplatform copied to clipboard
Setting cursor for window does not always behave as expected
Consider the following snippet:
fun main() = Window(title = "JFrame properties") {
var crosshairCursor by remember { mutableStateOf(false) }
onCommit(crosshairCursor) {
val jFrame = AppManager.focusedWindow?.window
jFrame?.let {
it.cursor =
if (crosshairCursor) Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR) else Cursor.getDefaultCursor()
}
}
MaterialTheme {
Button(onClick = { crosshairCursor = !crosshairCursor }) {
Text("Toggle crosshair cursor")
}
}
}
- Toggling the cursor via button press works fine
- Defocusing the window resets the cursor to the default cursor when re-entering the window.
- Refocusing the window via the dock icon uses the correct custom cursor again.

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.