From d04362ba824ce60bb12115330a0aa86e3bdce176 Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Sun, 29 Mar 2009 00:46:18 +0000 Subject: [PATCH] History fileview: select current item on rightclick --- PBQLOutlineView.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/PBQLOutlineView.m b/PBQLOutlineView.m index 4e620bd..24f43e1 100644 --- a/PBQLOutlineView.m +++ b/PBQLOutlineView.m @@ -58,6 +58,25 @@ 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; }