adte
03/07/2025, 10:39 PMvar pointerIcon by remember { mutableStateOf(state.mouseCursor.pointerIcon) }
// There is a bug with updating the cursor when going from one custom cursor to another.
// This is due to AWT Cursor equals() implementation that makes all custom cursors equal, so
// Compose skips the update.
// The trick is to set the default cursor momentarily before the new custom cursor, to force the
// change to be detected.
val mouseCursor = state.mouseCursor
LaunchedEffect(mouseCursor) {
pointerIcon = PointerIcon.Default
delay(16) // delay by a frame
pointerIcon = mouseCursor.pointerIcon
}
I also had to write a MouseCursor class that implements equality properly (it uses the resource path of the cursor image for custom cursors).ephemient
03/07/2025, 11:44 PMvar pointerIcon by remember { mutableStateOf(pointerIcon, referentialEqualityPolicy() }
or neverEqualPolicy()
adte
03/08/2025, 12:31 AMpointerIcon
fire a new state unfortunatelyjw
03/08/2025, 2:04 AMwithFrameNanos { }
adte
03/08/2025, 2:56 AM