Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pointer icons for native macOS #1703

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.ui.input.key.KeyEvent
import androidx.compose.ui.input.key.toComposeEvent
import androidx.compose.ui.input.pointer.PointerButton
import androidx.compose.ui.input.pointer.PointerEventType
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.platform.MacosTextInputService
import androidx.compose.ui.platform.PlatformContext
import androidx.compose.ui.platform.WindowInfoImpl
Expand All @@ -44,6 +45,7 @@ import org.jetbrains.skia.Canvas
import org.jetbrains.skiko.SkiaLayer
import org.jetbrains.skiko.SkikoRenderDelegate
import platform.AppKit.NSBackingStoreBuffered
import platform.AppKit.NSCursor
import platform.AppKit.NSEvent
import platform.AppKit.NSTrackingActiveAlways
import platform.AppKit.NSTrackingActiveInKeyWindow
Expand Down Expand Up @@ -93,6 +95,14 @@ private class ComposeWindow(
object : PlatformContext by PlatformContext.Empty {
override val windowInfo get() = _windowInfo
override val textInputService get() = macosTextInputService
override fun setPointerIcon(pointerIcon: PointerIcon) {
when (pointerIcon) {
igordmn marked this conversation as resolved.
Show resolved Hide resolved
PointerIcon.Default -> NSCursor.arrowCursor.set()
PointerIcon.Crosshair -> NSCursor.crosshairCursor.set()
PointerIcon.Text -> NSCursor.IBeamCursor.set()
PointerIcon.Hand -> NSCursor.pointingHandCursor.set()
}
}
}
private val skiaLayer = SkiaLayer()
private val scene = CanvasLayersComposeScene(
Expand Down