Last active
November 17, 2024 15:18
-
-
Save Amzd/cb8ba40625aeb6a015101d357acaad88 to your computer and use it in GitHub Desktop.
Set the cursor that is displayed when hovering a View. (macOS, SwiftUI)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@humblehacker We'll get it right eventually, meanwhile @apple has been ignoring this bug...