I have a tableview showing, an when the user clicks on the last column cell, I want to create and show a popover with more information. I’m almost there, but doing something wrong with creating my popover and the windowcontroller/view that it will house. I’m assigning something wrong.
Its failing with a message that my view controller or view is nil.
Here is my code:
method MainWindowController.tableView(tableView: not nullable NSTableView) shouldTrackCell(cell: not nullable NSCell) forTableColumn(tableColumn: nullable NSTableColumn) row(row: NSInteger): BOOL;
begin
case tableView of
myTableView:
begin
var ClickedCol := tableView.tableColumns.indexOfObject(tableColumn);
if (ClickedCol=6) and (CurrentJob<>nil) then
begin
var _nview := new NotesPopoverWindow;
var _npop := new NSPopover;
var popoverRect := myTableView.frameOfCellAtColumn(ClickedCol) row(row);
try
_npop.setBehavior(NSPopoverBehavior.NSPopoverBehaviorTransient);
_npop.setAnimates(true);
_npop.setContentSize(NSMakeSize(200,200));
_npop.setContentViewController(_nview.window.contentViewController);
_npop.showRelativeToRect(popoverRect) ofView(self.window.contentView) preferredEdge(NSRectEdge.NSMinYEdge);
except
on ex:Exception do
begin
NSLog(ex.message);
NSLog(ex.StackTrace);
end;
end;
end;
end;
end;
result := false;
end;