Skip to content

Instantly share code, notes, and snippets.

@Amzd
Last active February 9, 2024 17:34
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Amzd/cb8ba40625aeb6a015101d357acaad88 to your computer and use it in GitHub Desktop.
Save Amzd/cb8ba40625aeb6a015101d357acaad88 to your computer and use it in GitHub Desktop.
Set the cursor that is displayed when hovering a View. (macOS, SwiftUI)
import SwiftUI
extension View {
/// https://stackoverflow.com/a/61985678/3393964
public func cursor(_ cursor: NSCursor) -> some View {
self.onHover { inside in
if inside {
cursor.push()
} else {
NSCursor.pop()
}
}
}
}
@lucasfeijo
Copy link

@humblehacker We'll get it right eventually, meanwhile @apple has been ignoring this bug...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment