Skip to content

Commit

Permalink
History fileview: select current item on rightclick
Browse files Browse the repository at this point in the history
  • Loading branch information
Pieter de Bie committed Mar 29, 2009
1 parent 3c43655 commit c91dddc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions PBQLOutlineView.m
Expand Up @@ -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; }
Expand Down

0 comments on commit c91dddc

Please sign in to comment.