Created
August 6, 2021 10:20
-
-
Save xhruso00/426b3e87870373b75f87823da6d88bea to your computer and use it in GitHub Desktop.
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 Cocoa | |
class SomeView : NSView { | |
var trackingArea : NSTrackingArea? | |
override func draw(_ dirtyRect: NSRect) { | |
NSColor.red.setFill() | |
dirtyRect.fill() | |
} | |
override func updateTrackingAreas() { | |
super.updateTrackingAreas() | |
if trackingArea != nil { | |
removeTrackingArea(trackingArea!) | |
} | |
let aTrackingArea = NSTrackingArea(rect: bounds, options: [.cursorUpdate, .activeAlways], owner: self, userInfo: nil) | |
addTrackingArea(aTrackingArea) | |
self.trackingArea = aTrackingArea | |
} | |
override func cursorUpdate(with event: NSEvent) { | |
NSCursor.pointingHand.set() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment