compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

Setting cursor for window does not always behave as expected

Open SebastianAigner opened this issue 5 years ago • 1 comments

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.

Untitled

SebastianAigner avatar Oct 30 '20 14:10 SebastianAigner

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

okushnikov avatar Aug 26 '24 17:08 okushnikov