I have created an NSTrackingArea and I am passing a Dictionary in the userInfo argument.
let trackingData = ["section": 1, "sectionRow": 12, "done": false]
let trackingArea = NSTrackingArea(
rect: cellView.bounds,
options: [NSTrackingAreaOptions.MouseEnteredAndExited, NSTrackingAreaOptions.ActiveAlways],
owner: self,
userInfo: trackingData as? [String : AnyObject])
cellView.addTrackingArea(trackingArea)
This event is successfully received here;
override func mouseEntered(event: NSEvent) {
print("Mouse Entered \(event.userData)")
}
How can I read the values for section etc from userData?
Using your syntax
But if you pass the
donekey asIntwith value0or1rather thanBool, you don't need cast the values of the dictionary because it's distinct[String:Int]and
The optional bindings are for safety, if there are more events to receive and track.