diff --git a/PBQLOutlineView.m b/PBQLOutlineView.m index c9b2d3137..dd65c1296 100644 --- a/PBQLOutlineView.m +++ b/PBQLOutlineView.m @@ -58,6 +58,25 @@ - (NSArray *)outlineView:(NSOutlineView *)outlineView namesOfPromisedFilesDroppe return fileNames; } +- (NSMenu *)menuForEvent:(NSEvent *)theEvent +{ + if ([theEvent type] == NSRightMouseDown) + { + // get the current selections for the outline view. + NSIndexSet *selectedRowIndexes = [self selectedRowIndexes]; + + // select the row that was clicked before showing the menu for the event + NSPoint mousePoint = [self convertPoint:[theEvent locationInWindow] fromView:nil]; + int row = [self rowAtPoint:mousePoint]; + + // figure out if the row that was just clicked on is currently selected + if ([selectedRowIndexes containsIndex:row] == NO) + [self selectRow:row byExtendingSelection:NO]; + } + + return [super menuForEvent:theEvent]; +} + /* Implemented to satisfy datasourcee protocol */ - (BOOL) outlineView: (NSOutlineView *)ov isItemExpandable: (id)item { return NO; }