Vlad Gorbunov
11/30/2025, 5:23 PMpublic actual val PointerIcon.Companion.ZoomIn: PointerIcon
get() = customZoomInCursor
public actual val PointerIcon.Companion.ZoomOut: PointerIcon
get() = customZoomOutCursor
private val customZoomInCursor: PointerIcon by lazy {
val toolkit = Toolkit.getDefaultToolkit()
val customCursor = toolkit.createCustomCursor(DesignRes.images.cursor_zoom_in.image, Point(8, 8), "ZoomIn")
PointerIcon(customCursor)
}
private val customZoomOutCursor: PointerIcon by lazy {
val toolkit = Toolkit.getDefaultToolkit()
val customCursor = toolkit.createCustomCursor(DesignRes.images.cursor_zoom_out.image, Point(8, 8), "ZoomOut")
PointerIcon(customCursor)
}
I try to switch between them when my image scale changes
.pointerHoverIcon(if (scale >= 2f) PointerIcon.ZoomOut else PointerIcon.ZoomIn)
However, cursors do not change.
Upon investigating, I found out that internal AwtCursor does not implement hashCode and simply uses cursor.type value. Which is always -1 for both since it is a custom type indicator
public static final int CUSTOM_CURSOR = -1;
I've also found there is PointerIconService , but its internal and I can't plug my own.
Has anybody had same issue? How do I use multiple custom cursors?Vlad Gorbunov
11/30/2025, 5:27 PMoverride fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as AwtCursor
// AwtCursor doesn't implement equals
if (cursor.type != other.cursor.type) return false
return true
}
I think comparing cursor.type + cursor.name would do the trickVlad Gorbunov
11/30/2025, 5:33 PMAlexander Maryanovsky
12/02/2025, 8:01 AMadte
12/02/2025, 10:24 PMVlad Gorbunov
12/03/2025, 8:28 AMVlad Gorbunov
12/03/2025, 8:28 AM