I have a NSTableView and want to show a popOver if the User right click on a row. So i have this function:
override func rightMouseDown(theEvent: NSEvent) {
super.rightMouseDown(theEvent)
var point: NSPoint = talbeView.convertPoint(theEvent.locationInWindow, fromView: nil)
var row = tableView.rowAtPoint(point)
var rec = tableView.rectOfRow(row)
let storyboard = NSStoryboard(name: "Main", bundle: nil)
let popOverViewController = storyboard!.instantiateControllerWithIdentifier("RightMousPopOver") as! NSViewController
var cell: DocumentCellView = tableView.viewAtColumn(0, row: row, makeIfNecessary: true) as! DocumentCellView
self.presentViewController(popOverViewController, asPopoverRelativeToRect: rec, ofView: cell, preferredEdge: 2, behavior: NSPopoverBehavior.Transient)
}
But the popOver appears only if I right click on the first row. I have debug the row and its right. Also if i change the row manuelle, the popOver show on the right row, but again only if I click on the first row.
I'm little bit confused. What is wrong withe my code?
Ok i think i found the answer.
tableView.rectOfRow(row)
is false.cell.frame
is the right way to get the NSRec