I have an NSOutlineView which when a row in the outline view is double-clicked, an NSPopover is displayed using the following code:
-(void)doubleClick:(id)nid{
NSLog(@"Test double click");
[_popover showRelativeToRect:[nid bounds] ofView:nid preferredEdge:NSMaxXEdge];
}
The code works fine but places the popover in the middle of the vertical height of the outline view. I would like the popup to appear next to the row which is selected (double-clicked) in the outline view. Is there a call I can make to the Outline View to return the position of the selected row? I couldn't seem to find such a method in the documentation. Clearly I would replace [nid bounds] which such a call. Else, any other suggestions of how I could work around this would be appreciated.
Don't forget that NSOutlineView
inherits from NSTableView
. You're looking for -frameOfCellAtColumn:row:
. The column is probably 0. The row you can obtain with -selectedRow
.
If your outline view is view-based, you could also pass the row view (-rowViewAtRow:makeIfNecessary:
) and NSZeroRect
for the rect to -showRelativeToRect:...
, so it automatically tracks the row.