Post

Replies

Boosts

Views

Activity

Reply to NSCursor reset to arrow in macOS SwiftUI app
PS: That is how I use this solution in my app... .onHover { isHovered in self.imageHovered = isHovered DispatchQueue.main.async { if self.imageHovered { // Looks like ugly hack, but otherwise cursor gets reset to standard arrow. // See https://stackoverflow.com/a/62984079/7964697 for details. NSApp.windows.forEach { $0.disableCursorRects() } // swiftlint:disable:next force_unwrapping NSCursor(image: NSImage(named: "ZoomPlus")!, hotSpot: NSPoint(x: 9, y: 9)).push() // Cannot be nil. } else { NSCursor.pop() NSApp.windows.forEach { $0.enableCursorRects() } } } }
Jun ’22